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)
## plot the multiplicative effect of seasonality
plot(measlesFit, type="season")
## dominant eigenvalue of the Lambda matrix (cf. Held and Paul, 2012)
getMaxEV(measlesFit) # here simply constant and equal to exp(ar.1)
plot(measlesFit, type="maxEV") # not very exciting
## random intercepts of the endemic component
plot(measlesFit, type="ri", component="end", labels=list(font=3, labels="GEN"))
## neighbourhood weights as a function of neighbourhood order
plot(measlesFit, type="neweights") # boring, model has no "ne" component
## 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