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)

## 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.

## Value

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

Sebastian Funk

## Examples

# A fixed lognormal distribution with mean 5 and sd 1.
lognormal <- dist_spec(
mean = 1.6, sd = 1, max = 20, distribution = "lognormal"
)
lognormal + lognormal
#>
#>   Fixed distribution with PMF [0.0035 0.016 0.035 0.051 0.062 0.067 0.069 0.067 0.064 0.061 0.056 0.052 0.048 0.043 0.04 0.036 0.033 0.03 0.027 0.025 0.022 0.019 0.016 0.013 0.01 0.0079 0.0063 0.0049 0.0039 0.0031 0.0024 0.0019 0.0015 0.0012 0.00088 0.00066 0.00048]
#>

# 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
#>
#> Combination of delay distributions:
#>   Fixed distribution with PMF [0.059 0.14 0.14 0.12 0.095 0.078 0.064 0.053 0.044 0.037 0.031 0.026 0.022 0.019 0.017 0.015 0.013 0.011 0.0098 0.0086 0.0077]
#>   Uncertain gamma distribution with (untruncated) mean 3 (SD 0.5) and SD 2 (SD 0.5)
#>

# Using tolerance parameter
EpiNow2:::dist_spec_plus(lognormal, lognormal, tolerance = 0.5)
#>
#>   Fixed distribution with PMF [0.0064 0.03 0.064 0.093 0.11 0.12 0.12 0.12 0.12 0.11 0.1]
#>