Learn R Programming

EpiNow2 (version 1.4.0)

+.dist_spec: Creates a delay distribution as the sum of two other delay distributions

Description

This is done via convolution with stats::convolve(). Nonparametric delays that can be combined are processed together, and their cumulative distribution function is truncated at a specified tolerance level, ensuring numeric stability.

Usage

# S3 method for dist_spec
+(e1, e2)

Value

A delay distribution representing the sum of the two delays (with class dist_spec())

Arguments

e1

The first delay distribution (from a call to dist_spec()) to combine.

e2

The second delay distribution (from a call to dist_spec()) to combine.

Author

Sebastian Funk

Examples

Run this code
# A fixed lognormal distribution with mean 5 and sd 1.
lognormal <- dist_spec(
  mean = 1.6, sd = 1, max = 20, distribution = "lognormal"
)
lognormal + lognormal

# An uncertain gamma distribution with mean 3 and sd 2
gamma <- dist_spec(
  mean = 3, sd = 2, mean_sd = 0.5, sd_sd = 0.5, max = 20,
  distribution = "gamma"
)
lognormal + gamma

# Using tolerance parameter
EpiNow2:::dist_spec_plus(lognormal, lognormal, tolerance = 0.5)

Run the code above in your browser using DataLab