simulate_secondary: Simulate a secondary observation

simulate_secondaryR Documentation

Simulate a secondary observation

Description

Simulate a secondary observation

Usage

simulate_secondary(
  data,
  type = "incidence",
  family = "poisson",
  delay_max = 30,
  ...
)

Arguments

data

A data frame containing the date of report and primary cases as a numeric vector.

type

A character string indicating the type of observation the secondary reports are. Options include:

  • "incidence": Assumes that secondary reports equal a convolution of previously observed primary reported cases. An example application is deaths from an infectious disease predicted by reported cases of that disease (or estimated infections).

  • "prevalence": Assumes that secondary reports are cumulative and are defined by currently observed primary reports minus a convolution of secondary reports. An example application is hospital bed usage predicted by hospital admissions.

family

Character string defining the observation model. Options are Negative binomial ("negbin"), the default, Poisson ("poisson"), and "none" meaning the expectation is returned.

delay_max

Integer, defaulting to 30 days. The maximum delay used in the convolution model.

...

Additional parameters to pass to the observation model (i.e rnbinom or rpois).

Value

A data frame containing simulated data in the format required by estimate_secondary().

Author(s)

Sam Abbott

Sebastian Funk

See Also

estimate_secondary

Examples

# load data.table for manipulation
library(data.table)

#### Incidence data example ####

# make some example secondary incidence data
cases <- example_confirmed
cases <- as.data.table(cases)[, primary := confirm]

# Assume that only 40 percent of cases are reported
cases[, scaling := 0.4]

# Parameters of the assumed log normal delay distribution
cases[, meanlog := 1.8][, sdlog := 0.5]

# Simulate secondary cases
cases <- simulate_secondary(cases, type = "incidence")
cases
#### Prevalence data example ####

# make some example prevalence data
cases <- example_confirmed
cases <- as.data.table(cases)[, primary := confirm]

# Assume that only 30 percent of cases are reported
cases[, scaling := 0.3]

# Parameters of the assumed log normal delay distribution
cases[, meanlog := 1.6][, sdlog := 0.8]

# Simulate secondary cases
cases <- simulate_secondary(cases, type = "prevalence")
cases

EpiNow2 documentation built on Sept. 26, 2023, 5:11 p.m.