surveillance (version 1.12.1)

sts_animate: Animated Maps and Time Series of Disease Incidence

Description

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), 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.

Usage

## S3 method for class 'sts':
animate(object, tps = NULL, cumulative = FALSE,
        population = NULL, at = 10, ...,
        timeplot = list(height = 0.3),
        sleep = 0.5, verbose = interactive(), draw = TRUE)

Arguments

object
an object of class "sts" or a matrix of counts, i.e., observed(stsObj), where especially colnames(x) have to be contained in row.names(map). If a matrix, the
tps
a numeric vector of one or more time points at which to plot the map. The default tps=NULL means the whole time period 1:nrow(object).
cumulative
logical specifying if the cumulative counts over time should be plotted.
population,at,...
arguments for stsplot_space.
timeplot
if a list (of arguments for the internal function stsplot_timeSimple) and package gridExtra is available, a time series chart of the counts along the selected time points tps will be plotted below the map.
sleep
time to wait (Sys.sleep) between subsequent snapshots (only if dev.interactive), in seconds.
verbose
logical indicating if a txtProgressBar should be shown during generation of the animation -- which may take a while. Default is to do so in interacti
draw
logical indicating if the produced plots at each time point should be drawn directly (the default) or not. The setting draw = FALSE is useful if one would like to manually arrange the plots, which are always returned invisibly in

Value

  • (invisibly) a list of the length(tps) sequential plot objects of class "gtable" (if the the timeplot is active) or of class "trellis" (otherwise).

    Meyer, S. and Held, L. (2014): Power-law models for infectious disease spread. The Annals of Applied Statistics, 8 (3), 1612-1639. 10.1214/14-AOAS743. Supplement A is available from http://www.biostat.uzh.ch/static/powerlaw/.

    [object Object]

    the other plot types documented in stsplot for static time series plots and maps.

    data("measlesWeserEms")

    ## sequential plot of the counts by region in 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, cumulative=FALSE), title="Evolution of the measles epidemic in the Weser-Ems region", ani.width=500, ani.height=600) setwd(oldwd) }

    hplot dynamic spatial