plot(ts(count), xlab = "Week", ylab = "Number of Syphilis Cases",
main = "Maryland (2007 - 2010)", type = "o", pch = 20, las = 1)
table(count)
We first fit a ZIP autoregression with an AR(1) correlation structure. The linear trend is included in both the log-linear and logistic parts of the model.
m1 <- zim(count ~ count.lag1 + trend | trend)
m1
The EM-NR algorithm is used as the default algorithm in the zim function.
As suggested by the score test, we next fit a ZINB autoregression, with all the other components remaining the same as in the ZIP autoregression.
m2 <- zim(count ~ count.lag1 + trend | trend, dist = "zinb")
m2
The AIC and TIC suggest a marginal improvement when the ZINB autoregression is used. However, the BIC values for the ZIP and ZINB autoregressions are not distinguishable. This should not be surprising as BIC tends to penalize more for complexity.
We now fit a dynamic ZIP model to the syphilis data. The trend is included as a deterministic covariate in the log-linear model. The zero-inflation parameter is assumed to be constant over time.
set.seed(123)
system.time(m3 <- dzim(count ~ trend, dist = "zip", N = 200, R = 200, niter = 100))
m3
dzim.plot(m3)
We next fit a dynamic ZINB model to see whether a need remains for the NB dispersion parameter.
set.seed(123)
system.time(m4 <- dzim(count ~ trend, dist = "zinb", N = 200, R = 200, niter = 100))
m4
dzim.plot(m4)