Skip to contents

[Stable] Defines the parameters of a supported distribution for use in onward modelling. Multiple distribution families are supported - see the documentation for family for details. Alternatively, a nonparametric distribution can be specified using the pmf argument. This function provides distribution functionality in delay_opts(), generation_time_opts(), and trunc_opts().

Usage

dist_spec(
  mean,
  sd = 0,
  mean_sd = 0,
  sd_sd = 0,
  distribution = c("lognormal", "gamma"),
  max,
  pmf = numeric(0),
  fixed = FALSE
)

Arguments

mean

Numeric. If the only non-zero summary parameter then this is the fixed interval of the distribution. If the sd is non-zero then this is the mean of the distribution given by dist. If this is not given a vector of empty vectors is returned.

sd

Numeric, defaults to 0. Sets the standard deviation of the distribution.

mean_sd

Numeric, defaults to 0. Sets the standard deviation of the uncertainty around the mean of the distribution assuming a normal prior.

sd_sd

Numeric, defaults to 0. Sets the standard deviation of the uncertainty around the sd of the distribution assuming a normal prior.

distribution

Character, defaults to "lognormal". The (discretised distribution to be used. If sd == 0 then the distribution is fixed and a delta function is used. If sd > 0 then the distribution is discretised and truncated.

The following distributions are currently supported:

  • "lognormal" - a lognormal distribution. For this distribution mean is the mean of the natural logarithm of the delay (on the log scale) and sd is the standard deviation of the natural logarithm of the delay.

  • "gamma" - a gamma distribution. For this distribution mean is the mean of the delay and sd is the standard deviation of the delay. During model fitting these are then transformed to the shape and scale of the gamma distribution.

When distribution is the default lognormal distribution the other function arguments have the following definition:

  • mean is the mean of the natural logarithm of the delay (on the log scale).

  • sd is the standard deviation of the natural logarithm of the delay.

max

Numeric, maximum value of the distribution. The distribution will be truncated at this value.

pmf

Numeric, a vector of values that represent the (nonparametric) probability mass function of the delay (starting with 0); defaults to an empty vector corresponding to a parametric specification of the distribution (using mean, sd and corresponding uncertainties)

fixed

Logical, defaults to FALSE. Should delays be treated as coming from fixed (vs uncertain) distributions. Overrides any values assigned to mean_sd and sd_sd by setting them to zero. reduces compute requirement but may produce spuriously precise estimates.

Value

A list of distribution options.

Author

Sebastian Funk

Sam Abbott

Examples

# A fixed lognormal distribution with mean 5 and sd 1.
dist_spec(mean = 5, sd = 1, max = 20, distribution = "lognormal")
#> 
#>   Fixed distribution with PMF [1.3e-05 0.00035 0.0018 0.0046 0.0088 0.014 0.02 0.027 0.035 0.043 0.051 0.058 0.066 0.074 0.082 0.089 0.096 0.1 0.11 0.12]
#> 

# An uncertain gamma distribution with mean 3 and sd 2
dist_spec(
  mean = 3, sd = 2, mean_sd = 0.5, sd_sd = 0.5, max = 20,
  distribution = "gamma"
)
#> 
#>   Uncertain gamma distribution with (untruncated) mean 3 (SD 0.5) and SD 2 (SD 0.5)
#>