Creates a delay distribution as the sum of two other delay distributions
Source:R/dist.R
plus-.dist_spec.Rd
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.
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()
)
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.0036 0.017 0.036 0.052 0.063 0.068 0.07 0.068 0.065 0.062 0.057 0.053 0.048 0.044 0.04 0.037 0.033 0.03 0.027 0.025 0.022 0.018 0.014 0.011 0.0087 0.0068 0.0054 0.0042 0.0033 0.0026 0.002 0.0015 0.0012 0.00087 0.00063]
#>
# 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.06 0.14 0.14 0.12 0.096 0.079 0.065 0.053 0.044 0.037 0.031 0.027 0.023 0.019 0.017 0.015 0.013 0.011 0.0099 0.0087]
#> 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.0071 0.033 0.071 0.1 0.12 0.14 0.14 0.14 0.13 0.12]
#>