sts_animate: Animated Maps and Time Series of Disease Incidence

Description Usage Arguments Value Author(s) References See Also Examples

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

1
2
3
4
5
## 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 map object has to be provided explicitly (as part of ...).

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. The argument height gives the relative height of the time series plot (default: 0.3), and the arguments inactive and active are lists of graphical parameters (e.g., col) determining the appearance of the bars (e.g., default color is grey when inactive and black when active).

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 interactive sessions.

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 a list of length length(tps).

Value

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

Author(s)

Sebastian Meyer

References

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

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)
}

jimhester/surveillance documentation built on May 19, 2019, 10:33 a.m.