# some calls of the fitting function 'hhh4':
# see vignette("hhh4") for further details
data("influMen")
fluMen <- disProg2sts(influMen)
meningo <- fluMen[, "meningococcus"]
## 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, 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 transmission from flu to men
# endemic component: S=3 and S=1 sine/cosine pairs for flu and men, respectively
Wflumen <- neighbourhood(fluMen)
Wflumen["meningococcus","influenza"] <- 0
Wflumen
f.end <- addSeason2formula(f = ~ -1 + fe(1, which = c(TRUE,TRUE)),
S = c(3, 1), period = 52)
f.end
m <- list(ar = list(f = ~ -1 + fe(1, unitSpecific = TRUE)),
ne = list(f = ~ 1, weights = Wflumen),
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
data("fluBYBW")
f.end <- addSeason2formula(f = ~ -1 + ri(type = "iid", corr="all") +
I((t-208)/100), S = 3, period = 52)
wji <- neighbourhood(fluBYBW)/rowSums(neighbourhood(fluBYBW))
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(fluBYBW)),
family = "NegBin1", verbose = TRUE)
hhh4(fluBYBW, model.B2)
Run the code above in your browser using DataLab