I am trying to do an interaction analysis using gnm in Distributed Lag Non-Linear Model (dlnm) library. My script works fine in its simple form with effect and crossbasis of exposure as well as with confounders, but when I try to factor in a new variable for an interaction analysis, it is showing : Error in crosspred(cb_pm25, model_pm25) :
coef/vcov not consistent with basis matrix. See help(crosspred).
My code is:
argvar <- list(fun="ns", knots=quantile(data_long$PM25, c(10,90)/100, na.rm=T))
arglag <- list(fun="ns", df=3)
cb_pm25 <- crossbasis(data_long$PM25, lag =7, argvar = argvar,
arglag = arglag, group = data_long$year)
model_pm25 <- gnm(cases ~ cb_pm25:factor(int_time), eliminate=stratum, data=data_long, family=quasipoisson, subset=keep)
pred_pm25 <- crosspred(cb_pm25, model_pm25)
Also, unique(data_long$int_time) : “11to14” “9to10” “below8” “over15”
Please help me in pointing out where am I going wrong. Thanks in advance.