Learn R Programming

surveillance: Temporal and Spatio-Temporal Modeling and Monitoring of Epidemic Phenomena

The open-source R package surveillance implements statistical methods for the modeling and monitoring of epidemic phenomena based on (infectious disease) surveillance data. This includes time series of counts, proportions and categorical data as well as spatio-temporal point processes. Potential users are biostatisticians, epidemiologists and others working in, e.g., applied infectious disease epidemiology. However, applications could just as well originate from environmetrics, reliability engineering, econometrics or the social sciences.

Prospective outbreak detection

Salmon et al. (2016) provide an overall guide to the monitoring capabilities of surveillance. The paper is available as vignette("monitoringCounts") with the package. Further descriptions can be found in a book chapter by Höhle and Mazick (2010, preprint), and -- slightly outdated -- Höhle (2007) or vignette("surveillance").

  • Aberration detection in count data time series, e.g., farringtonFlexible().

  • Online change-point detection in categorical time series, e.g., categoricalCUSUM().
    A Markov Chain approximation for computing the run-length distribution of the proposed likelihood ratio CUSUMs is available as function LRCUSUM.runlength().

See the online reference index for the complete list of algorithms.

Modeling reporting delays

  • Backprojection methods: backprojNP()

  • Adjusting for occurred-but-not-yet-reported events: nowcast(), bodaDelay()

Endemic-epidemic modeling

Meyer et al. (2017) provide a guide to the spatio-temporal modeling capabilities of surveillance. These so-called endemic-epidemic models have proven useful in a wide range of applications, also beyond epidemiology. A list of corresponding publications is maintained at https://surveillance.R-forge.R-project.org/applications_EE.html.

twinstim()

  • models a spatio-temporal point pattern of infective events
  • is described in vignette("twinstim")
  • needs data of class "epidataCS", which holds the observed events (with covariates) and exogenous covariates on a space-time grid (for the endemic/background component)
  • features a model-based epitest() for space-time interaction

twinSIR()

  • models the susceptible-infectious-recovered (SIR) event history of a fixed population
  • is described in vignette("twinSIR")
  • needs data of class "epidata"

hhh4()

  • models a (multivariate) time series of infectious disease counts
  • is described in vignette("hhh4_spacetime") for areal time series, and more generally in vignette("hhh4"), including the univariate case
  • needs data of class "sts" (see below)

Data class "sts"

The S4 class "sts" (surveillance time series), created via sts() or linelist2sts(), represents (multivariate) time series of counts. For areal time series, the class can also capture population fractions, a map, and a weight matrix.

For evaluation purposes, the package contains several datasets derived from the SurvStat@RKI database maintained by the Robert Koch Institute in Germany. See the online reference index for the complete list of datasets.

Installation

The stable release version of surveillance is hosted on the Comprehensive R Archive Network (CRAN) at https://CRAN.R-project.org/package=surveillance and can be installed via

install.packages("surveillance")

The development version of surveillance is hosted on R-Forge at https://R-Forge.R-project.org/projects/surveillance/ in a Subversion (SVN) repository. It can be installed via

install.packages("surveillance", repos = "https://R-Forge.R-project.org")

Alternatively, a development build can be installed from the R-universe mirror of R-Forge.

Feedback

Contributions are welcome! Please report bugs via e-mail to maintainer("surveillance").

Note that (large) new features are unlikely to be included in surveillance. Some extensions have already been developed in separate packages, for example hhh4contacts, HIDDA.forecasting, hhh4addon, and hhh4ZI.

Funding

The authors acknowledge financial support from the following institutions:

License

The surveillance package is free and open-source software, and you are welcome to redistribute it under the terms of the GNU General Public License, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.

Copy Link

Version

Install

install.packages('surveillance')

Monthly Downloads

1,452

Version

1.25.0

License

GPL-2

Maintainer

Sebastian Meyer

Last Published

June 25th, 2025

Functions in surveillance (1.25.0)

aggregate.disProg

Aggregate a disProg Object
addSeason2formula

Add Harmonics to an Existing Formula
MMRcoverageDE

MMR coverage levels in the 16 states of Germany
abattoir

Abattoir Data
algo.cdc

The CDC Algorithm
algo.bayes

The Bayes System
algo.call

Query Transmission to Specified Surveillance Algorithm
addFormattedXAxis

Formatted Time Axis for "sts" Objects
LRCUSUM.runlength

Run length computation of a CUSUM detector
R0

Computes reproduction numbers from fitted models
algo.compare

Comparison of Specified Surveillance Systems using Quality Values
algo.glrnb

Count Data Regression Charts
algo.farrington.fitGLM

Fit Poisson GLM of the Farrington procedure for a single time point
algo.hmm

Hidden Markov Model (HMM) method
algo.quality

Computation of Quality Values for a Surveillance System Result
algo.farrington.threshold

Compute prediction interval for a new observation
algo.farrington.assign.weights

Assign weights to base counts
algo.farrington

Surveillance for Count Time Series Using the Classic Farrington Method
algo.cusum

CUSUM method
algo.outbreakP

Semiparametric surveillance of outbreaks
anscombe.residuals

Compute Anscombe Residuals
arlCusum

Calculation of Average Run Length for discrete CUSUM schemes
all.equal

Test if Two Model Fits are (Nearly) Equal
algo.rki

The system used at the RKI
bestCombination

Partition of a number into two factors
algo.rogerson

Modified CUSUM method as proposed by Rogerson and Yamada (2004)
backprojNP

Non-parametric back-projection of incidence cases to exposure cases using a known incubation time as in Becker et al (1991)
animate

Generic animation of spatio-temporal objects
algo.summary

Summary Table Generation for Several Disease Chains
boda

Bayesian Outbreak Detection Algorithm (BODA)
bodaDelay

Bayesian Outbreak Detection in the Presence of Reporting Delays
campyDE

Campylobacteriosis and Absolute Humidity in Germany 2002-2011
categoricalCUSUM

CUSUM detector for time-varying categorical time series
create.disProg

Creating an object of class disProg (DEPRECATED)
coeflist

List Coefficients by Model Component
calibrationTest

Calibration Tests for Poisson or Negative Binomial Predictions
disProg2sts

Convert disProg object to sts and vice versa
deleval

Surgical Failures Data
clapply

Conditional lapply
checkResidualProcess

Check the residual process of a fitted twinSIR or twinstim
earsC

Surveillance for a count data time series using the EARS C1, C2 or C3 method and its extensions
epidataCS_update

Update method for "epidataCS"
epidataCS_animate

Spatio-Temporal Animation of a Continuous-Time Continuous-Space Epidemic
epidataCS_plot

Plotting the Events of an Epidemic over Time and Space
epidataCS_aggregate

Conversion (aggregation) of "epidataCS" to "epidata" or "sts"
epidataCS

Continuous Space-Time Marked Point Patterns with Grid-Based Covariates
discpoly

Polygonal Approximation of a Disc/Circle
epidata

Continuous-Time SIR Event History of a Fixed Population
epidataCS_permute

Randomly Permute Time Points or Locations of "epidataCS"
epidata_animate

Spatio-Temporal Animation of an Epidemic
findK

Find Reference Value
find.kh

Determine the k and h values in a standard normal setting
findH

Find decision interval for given in-control ARL and reference value
epidata_summary

Summarizing an Epidemic
farringtonFlexible

Surveillance for Univariate Count Time Series Using an Improved Farrington Method
fanplot

Fan Plot of Forecast Distributions
epidata_plot

Plotting the Evolution of an Epidemic
fluBYBW

Influenza in Southern Germany
estimateGLRNbHook

Hook function for in-control mean estimation
epidata_intersperse

Impute Blocks for Extra Stops in "epidata" Objects
hcl.colors

HCL-based Heat Colors from the colorspace Package
glm_epidataCS

Fit an Endemic-Only twinstim as a Poisson-glm
hhh4_W_utils

Extract Neighbourhood Weights from a Fitted hhh4 Model
formatPval

Pretty p-Value Formatting
hagelloch

1861 Measles Epidemic in the City of Hagelloch, Germany
hepatitisA

Hepatitis A in Germany
formatDate

Convert Dates to Character (Including Quarter Strings)
hhh4_W

Power-Law and Nonparametric Neighbourhood Weights for hhh4-Models
ha

Hepatitis A in Berlin
hhh4

Fitting HHH Models with Random Effects and Neighbourhood Structure
hhh4_update

update a fitted "hhh4" model
hhh4_predict

Predictions from a hhh4 Model
hhh4_plot

Plots for Fitted hhh4-models
hhh4_simulate_plot

Plot Simulations from "hhh4" Models
hhh4_simulate_scores

Proper Scoring Rules for Simulations from hhh4 Models
hhh4_internals

Internal Functions Dealing with hhh4 Models
hhh4_simulate

Simulate "hhh4" Count Time Series
hhh4_validation

Predictive Model Assessment for hhh4 Models
hhh4_methods

Print, Summary and other Standard Methods for "hhh4" Objects
hhh4_formula

Specify Formulae in a Random Effects HHH Model
isoWeekYear

Find ISO Week and Year of Date Objects
influMen

Influenza and meningococcal infections in Germany, 2001-2006
husO104Hosp

Hospitalization date for HUS cases of the STEC outbreak in Germany, 2011
intensityplot

Plot Paths of Point Process Intensities
knox

Knox Test for Space-Time Interaction
imdepifit

Example twinstim Fit for the imdepi Data
intersectPolyCircle

Intersection of a Polygonal and a Circular Domain
imdepi

Occurrence of Invasive Meningococcal Disease in Germany
ks.plot.unif

Plot the ECDF of a uniform sample with Kolmogorov-Smirnov bounds
layout.labels

Layout Items for spplot
marks

Import from package spatstat.geom
measles.weser

Measles in the Weser-Ems region of Lower Saxony, Germany, 2001-2002
multiplicity

Import from package spatstat.geom
magic.dim

Compute Suitable k1 x k2 Layout for Plotting
meningo.age

Meningococcal infections in France 1985-1997
m1

RKI SurvStat Data
measlesDE

Measles in the 16 states of Germany
momo

Danish 1994-2008 all-cause mortality data for eight age groups
makeControl

Generate control Settings for an hhh4 Model
linelist2sts

Convert Dates of Individual Case Reports into a Time Series of Counts
pairedbinCUSUM

Paired binary CUSUM and its run-length computation
plot.disProg

Plot Observed Counts and Defined Outbreak States of a (Multivariate) Time Series
multiplicity.Spatial

Count Number of Instances of Points
plot.survRes

Plot a survRes object
nowcast

Adjust a univariate time series of counts for observed but-not-yet-reported events
permutationTest

Monte Carlo Permutation Test for Paired Individual Scores
poly2adjmat

Derive Adjacency Structure of "SpatialPolygons"
nbOrder

Determine Neighbourhood Order Matrix from Binary Adjacency Matrix
plapply

Verbose and Parallel lapply
pit

Non-Randomized Version of the PIT Histogram (for Count Data)
print.algoQV

Print Quality Value Object
refvalIdxByDate

Compute indices of reference value using Date class
rotaBB

Rotavirus cases in Brandenburg, Germany, during 2002-2013 stratified by 5 age categories
salmAllOnset

Salmonella cases in Germany 2001-2014 by data of symptoms onset
polyAtBorder

Indicate Polygons at the Border
runifdisc

Sample Points Uniformly on a Disc
primeFactors

Prime Number Factorization
residualsCT

Extract Cox-Snell-like Residuals of a Fitted Point Process
ranef

Import from package nlme
salmHospitalized

Hospitalized Salmonella cases in Germany 2004-2014
sim.pointSource

Simulate Point-Source Epidemics
sim.seasonalNoise

Generation of Background Noise for Simulated Timeseries
aggregate-methods

Aggregate an "sts" Object Over Time or Across Units
sts-class

Class "sts" -- surveillance time series
scores

Proper Scoring Rules for Poisson or Negative Binomial Predictions
shadar

Salmonella Hadar cases in Germany 2001-2006
salmNewport

Salmonella Newport cases in Germany 2004-2013
salmonella.agona

Salmonella Agona cases in the UK 1990-1995
sts_creation

Simulate Count Time Series with Outbreaks
sts_observation

Create an sts object with a given observation date
stsNewport

Salmonella Newport cases in Germany 2001-2015
stsSlot-generics

Generic Functions to Access "sts" Slots
stsNClist_animate

Animate a Sequence of Nowcasts
stK

Diggle et al (1995) K-function test for space-time clustering
stcd

Spatio-temporal cluster detection
sts_animate

Animated Maps and Time Series of Disease Counts or Incidence
sts_ggplot

Time-Series Plots for "sts" Objects Using ggplot2
stsXtrct

Subsetting "sts" Objects
stsBP-class

Class "stsBP" -- a class inheriting from class sts which allows the user to store the results of back-projecting or nowcasting surveillance time series
stsNC-class

Class "stsNC" -- a class inheriting from class sts which allows the user to store the results of back-projecting surveillance time series
twinSIR_cox

Identify Endemic Components in an Intensity Model
tidy.sts

Convert an "sts" Object to a Data Frame in Long (Tidy) Format
toLatex.sts

toLatex-Method for "sts" Objects
surveillance.options

Options of the surveillance Package
stsplot_space

Map of Disease Counts/Incidence accumulated over a Given Period
twinSIR

Fit an Additive-Multiplicative Intensity Model for SIR Data
surveillance-defunct

Defunct Functions in Package surveillance
surveillance-package

surveillance: tools:::Rd_package_title("surveillance")
stsplot

Plot Methods for Surveillance Time-Series Objects
stsplot_time

Time-Series Plots for "sts" Objects
twinSIR_methods

Print, Summary and Extraction Methods for "twinSIR" Objects
twinSIR_exData

Toy Data for twinSIR
twinSIR_simulation

Simulation of Epidemic Data
twinstim_iafplot

Plot the Spatial or Temporal Interaction Function of a twimstim
twinstim_intensity

Plotting Intensities of Infection over Time or Space
twinSIR_intensityplot

Plotting Paths of Infection Intensities for twinSIR Models
twinstim_epitest

Permutation Test for Space-Time Interaction in "twinstim"
twinstim_iaf

Temporal and Spatial Interaction Functions for twinstim
twinSIR_profile

Profile Likelihood Computation and Confidence Intervals
twinstim

Fit a Two-Component Spatio-Temporal Point Process Model
siaf.simulatePC

Simulation from an Isotropic Spatial Kernel via Polar Coordinates
twinstim_simEndemicEvents

Quick Simulation from an Endemic-Only twinstim
twinstim_methods

Print, Summary and Extraction Methods for "twinstim" Objects
twinstim_profile

Profile Likelihood Computation and Confidence Intervals for twinstim objects
twinstim_step

Stepwise Model Selection by AIC
twinstim_plot

Plot methods for fitted twinstim's
twinstim_siaf

Spatial Interaction Function Objects
twinstim_tiaf

Temporal Interaction Function Objects
twinstim_simulation

Simulation of a Self-Exciting Spatio-Temporal Point Process
twinstim_update

update-method for "twinstim"
wrap.algo

Multivariate Surveillance through independent univariate algorithms
unionSpatialPolygons

Compute the Unary Union of "SpatialPolygons"
zetaweights

Power-Law Weights According to Neighbourhood Order
untie

Randomly Break Ties in Data