With regards to autocorrelation, how can glmmTMB
tell how far apart time steps are if the time sequence must be provided to ar1()
as a factor?
In glmmTMB
, ar1
requires timesteps to be evenly spaced and to be coded as a factor (see this vignette). Given a numerical time series time.steps
, is it enough to recode it as as.factor(time.steps)
for the model to run correctly? How can glmmTMB
tell how far apart moments in time are if the time sequence must be provided as a factor?
is it enough to recode it as as.factor(time.steps) for the model to run correctly?
Yes.
How can glmmTMB tell how far apart moments in time are if the time sequence must be provided as a factor?
The assumption is that successive levels of the factor are one time step apart (the ar1()
covariance structure does not allow for unevenly spaced time steps: for that you need the ou()
covariance structure, for which you need to use numFactor()
to encode the time values).
For a little more detail: the correlation structure for an AR1-structured random effect is
1 rho rho^2 rho^3 ...
rho 1 rho rho^2 ...
rho^2 rho 1 rho ...
rho^3 rho^2 rho 1 ...
... ... ... ... ...
where the row/column positions correspond to time steps/levels of the factor. So we really don't need to know anything more than the order of the time steps, which is specified by the order of the levels of the factor.