Animated Maps and Time Series of Disease Counts or Incidence
The animate
-method for sts
objects
supersedes the stsplot
type observed~1|unit*time
implemented by the function stsplot_spacetime
.
Maps generated by stsplot_space
are
sequentially plotted along time (optionally showing cumulative
counts/incidence), with an optional time series chart below the map
to track the epidemic curve.
It is worth using functionality of the animation package
(e.g., saveHTML
) to directly export the
animation into a useful format.
See Meyer and Held (2014, Supplement A) for an example with the
fluBYBW
data.
## S3 method for class 'sts' animate(object, tps = NULL, cumulative = FALSE, population = NULL, at = 10, ..., timeplot = list(pos = 1, size = 0.3, fill = TRUE), sleep = 0.5, verbose = interactive(), draw = TRUE)
object |
an object of class |
tps |
a numeric vector of one or more time points at which to plot the map.
The default |
cumulative |
logical specifying if the cumulative counts/incidence over time
should be plotted. The cumulative incidence is relative to the
population from the first time point |
population,at,... |
arguments for |
timeplot |
if a list and package gridExtra is available,
a time series chart of the counts along
the selected time points |
sleep |
time to wait ( |
verbose |
logical indicating if a |
draw |
logical indicating if the produced plots at each time point should
be drawn directly (the default) or not.
The setting |
Sebastian Meyer
Meyer, S. and Held, L. (2014):
Power-law models for infectious disease spread.
The Annals of Applied Statistics, 8 (3), 1612-1639.
doi: 10.1214/14-AOAS743.
Supplement A is available from
https://www.biostat.uzh.ch/static/powerlaw/.
the other plot types documented in stsplot
for static
time series plots and maps.
data("measlesWeserEms") ## animate the weekly counts of measles (during weeks 12-16 only, for speed) if (require("animation")) { oldwd <- setwd(tempdir()) # to not clutter up the current working dir saveHTML(animate(measlesWeserEms, tps=12:16), title="Evolution of the measles epidemic in the Weser-Ems region", ani.width=500, ani.height=600) setwd(oldwd) } ## Not run: ## animate the weekly incidence of measles (per 100'000 inhabitants), ## and label the time series plot with dates in a specified format animate(measlesWeserEms, tps=12:16, population = measlesWeserEms@map$POPULATION / 100000, timeplot = list(as.Date = TRUE, scales = list(x = list(format = "%G/%V")))) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.