# some calls of the fitting function 'hhh4':
# see vignette("hhh4") for further details
## Ex: univariate time series of meningococcal infections in Germany
# Negative binomial model with
# endemic component: Intercept + S = 1 sine/cosine pair
# autoregressive component: Intercept
f.S1 <- addSeason2formula(f = ~ 1, S = 1, period = 52)
hhh4(meningo, control = list(ar = list(f = ~ 1),
end = list(f = f.S1),
family = "NegBin1"))
## Ex: disease-specific intercept in influenza/meningococcal time series
# Negative binomial model with
# autoregressive component: disease-specific intercepts
# neighbour-driven component: only intercept for flu -> men
# endemic component: S=3 and S=1 sine/cosine pairs for flu and men, respectively
f.end <- addSeason2formula(f = ~ -1 + fe(1, which = c(TRUE, TRUE)),
S = c(3, 1),
period = 52)
m <- list(ar = list(f = ~ -1 + fe(1, which = c(TRUE, TRUE))),
ne = list(f = ~ -1 + fe(1, which = c(FALSE, TRUE))),
end = list(f = f.end),
family = "NegBinM"
)
hhh4(fluMen, control = m)
## Ex: (correlated) random intercepts for influenza in Southern Germany
# Negative binomial model with
# autoregressive component: Intercept
# neighbour-driven component: random intercepts
# endemic component: random intercepts + trend + S = 3 sine/cosine pairs
f.end <- addSeason2formula(f = ~ -1 + ri(type = "iid", corr="all") +
I((t-208)/100), S = 3, period = 52)
model.B2 <- list(ar = list(f = ~ 1),
ne = list(f = ~ -1 + ri(type = "iid", corr="all"),
weights = wji),
end = list(f = f.end, offset = population(flu)),
family = "NegBin1")
hhh4(flu, model.B2)
## Ex: measles in Germany
# Poisson model with
# autoregressive component: Intercept + vaccination coverage info
# endemic component: Intercept + S = 1 sine/cosine pair
f.end <- addSeason2formula(f = ~ 1, S = 1, period = 26)
model.A0 <- list(ar = list(f = ~ 1 + logVac0),
end = list(f = f.end, offset = population(measles2w)),
data = list(t = epoch(measles2w), logVac0 = log(vac0)))
hhh4(measles2w, model.A0)
Run the code above in your browser using DataLab