I have a timeseries data where the response variable is autocorrelated in time, like this:
library(tseries)
testdat <- data.frame(time = as.factor(rep(c(1:10),20)),
y = rep(arima.sim(model = list(ar = .75), n = 20, innov = runif(100, 0, 1)),10),
group = rep(1:20,10))
Now I would like to test for AR(2), instead of the ar1() argument. Is there a quick fix in either the “time” column in my data or the code?
I have tried going into glmmTMB:::formatVC but could only get the corr value for AR(2). Also there was little luck trying to find the covariance matrix in the results:
m <- glmmTMB(y ~ ar1(time + 0|group) , data = testdat, family = poisson, doFit = F)
View(m)
Am I looking for the right place? Or can I modify the source code to generate AR(2)?
Li W is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.