data("measlesWeserEms")
## fit a simple hhh4 model
measlesModel <- list(
ar = list(f = ~ 1),
end = list(f = addSeason2formula(~0 + ri(type="iid"), S=1, period=52),
offset = population(measlesWeserEms)),
family = "NegBin1"
)
measlesFit <- hhh4(measlesWeserEms, measlesModel)
## fitted values for a single unit
plot(measlesFit, units=2)
## seasonality plot
plot(measlesFit, type="season")
## dominant eigenvalue of the Lambda matrix (cf. Held and Paul, 2012)
getMaxEV_season(measlesFit)$maxEV.const # here simply exp(AR intercept)
plot(measlesFit, type="maxEV") # not very exciting here since constant
## random intercepts of the endemic component
plot(measlesFit, type="ri", component="end")
## fitted values for the 6 regions with most cases and some customization
bigunits <- tail(names(sort(colSums(observed(measlesWeserEms)))), 6)
plot(measlesFit, units=bigunits,
names=measlesWeserEms@map@data[bigunits,"GEN"],
legend=5, legend.args=list(x="top"), xlab="Time (weekly)",
hide0s=TRUE, ylim=c(0,max(observed(measlesWeserEms)[,bigunits])),
start=c(2002,1), end=c(2002,26), par.settings=list(xaxs="i"))
Run the code above in your browser using DataLab