I am trying to understand why specifying AR-1 covariance structure in conditional formula estimates 2 parameters (like it should), but estimates many parameters when specified in zero-inflation formula. A small example (replicated from "Covariance structures with glmmTMB" tutorial) using simulated data is shown below.
n <- 25 ## Number of time points
x <- MASS::mvrnorm(mu = rep(0,n),
Sigma = .7 ^ as.matrix(dist(1:n)) ) ## Simulate the process using the MASS package
y <- x + rnorm(n) ## Add measurement noise
times <- factor(1:n, levels=1:n)
head(levels(times))
group <- factor(rep(1,n))
dat0 <- data.frame(y, times, group)
library(glmmTMB)
model <- glmmTMB(y ~ ar1(factor(times) + 0 | group), ziformula = ~ ar1(factor(times) + 0 | group), data=dat0, family = gaussian())
summary(model)
The model result looks like this:-
The result looks contrary to expectation since AR-1 should only estimate two parameters: sigma (reported as "Std.Dev." in conditional model) and rho (reported as "Corr" in the conditional model). Could anyone shed some light on this?
Is my understanding correct or flawed? Am I missing something or is this a package issue?
This is a printing problem, which should probably be reported to the glmmTMB issues list.
Despite the fact that summary()
prints a full correlation matrix, you can infer that only a single parameter is actually estimated: the values in any column of the correlation matrix (-0.98, 0.95, -0.93, 0.91, -0.89, ...) represent the correlation parameter raised to successively higher powers (phi^i
). You can also see that all the variances and standard deviations are identical. So in fact glmmTMB
is only estimating two parameters (std dev = 0.003747, phi = -0.98), it's just reporting the results in a clunky way.
Now fixed in a pull request