simulate_delayed_observations: Simulate a series of delayed observations from a series of...

View source: R/simulate.R

simulate_delayed_observationsR Documentation

Simulate a series of delayed observations from a series of infections.

Description

Simulate a series of delayed observations from a series of infections.

Usage

simulate_delayed_observations(
  infections,
  delay,
  noise = list(type = "noiseless")
)

Arguments

infections

Positive integer vector. Course of infections through time.

delay

Single delay or list of delays. Each delay can be one of:

  • a list representing a distribution object

  • a discretized delay distribution vector

  • a discretized delay distribution matrix

  • a dataframe containing empirical delay data

noise

List specifying the type of noise and its parameters, if applicable.

Value

Integer vector. Simulated delayed observations.

Examples

## Basic usage of simulate_delayed_observations
# Simulating a series of delayed observations of infections generated by an 
# infection with a Re of 1.2. The delays of the observations follow a normal
# distribution.
set.seed(7)
infections <- simulate_infections(rep(1.5, 100))


delay <- list(name="norm", mean = 7, sd = 2)

delayed_observations_1 <- simulate_delayed_observations(
  infections,
  delay = delay
)

## Advanced usage of simulate_delayed_observations
# Simulating delayed observations using the same infections as above, but assuming
# the observation is delayed by a convolution of two different delays

shape_incubation = 3.2
scale_incubation = 1.3
delay_incubation <- list(name="gamma", shape = shape_incubation, scale = scale_incubation)

shape_onset_to_report = 2.7
scale_onset_to_report = 1.6
delay_onset_to_report <- list(name="gamma",
                              shape = shape_onset_to_report,
                              scale = scale_onset_to_report)

delayed_observations_2 <- simulate_delayed_observations(
  infections,
  delay = list(delay_incubation, delay_onset_to_report)
)

# Simulating noisy delayed observations, assuming a gaussian noise 
delayed_observations_3 <- simulate_delayed_observations(
  infections,
  delay = delay,
  noise = list(type = 'gaussian', sd = 0.8)
)

covid-19-Re/estimateR documentation built on Sept. 14, 2024, 5:49 a.m.