I would like to fit a generalized linear mixed effect model using an AR1 correlation structure in the R package glmmTMB
. After checking the documentation
... it seems that "time" must be fitted as a factor for the random effects component i.e.
glmmTMB(y ~ ar1(time_fac + 0 | group), data=dat0, family=binomial(link = "logit"))
However, I wondered if it makes sense to fit this kind of model:
glmmTMB(y ~ ns(time_cont,3) + ar1(time_fac + 0 | group),
data=dat0, family=binomial(link = "logit"))
Here I have specified the fixed effect time to be a continuous natural spline whilst retaining time as a factor for the ar1 component. The model does fit, but I am not sure if it makes sense. Also I have not really seen an explanation of WHY time must be coded as a factor for the AR1 component, and why we cannot fit a random slope?