convolve_and_scale {EpiNow2} | R Documentation |
Convolve and scale a time series
Description
This applies a lognormal convolution with given, potentially time-varying
parameters representing the parameters of the lognormal distribution used for
the convolution and an optional scaling factor. This is akin to the model
used in estimate_secondary()
and simulate_secondary()
.
Usage
convolve_and_scale(
data,
type = c("incidence", "prevalence"),
family = c("none", "poisson", "negbin"),
delay_max = 30,
...
)
Arguments
data |
A |
type |
A character string indicating the type of observation the secondary reports are. Options include:
|
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
|
Details
Up to version 1.4.0 this function was called simulate_secondary()
.
Value
A <data.frame>
containing simulated data in the format required by
estimate_secondary()
.
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 <- convolve_and_scale(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 <- convolve_and_scale(cases, type = "prevalence")
cases