These functions performs maximum-likelihood (ML) fitting of a discretised distribution. This is typically useful for describing delays between epidemiological events, such as incubation period (infection to onset) or serial intervals (primary to secondary onsets). The function optim is used internally for fitting.

fit_disc_gamma(x, mu_ini = 1, cv_ini = 1, interval = 1, w = 0, ...)

Arguments

x

A vector of numeric data to fit; NAs will be removed with a warning.

mu_ini

The initial value for the mean 'mu', defaulting to 1.

cv_ini

The initial value for the coefficient of variation 'cv', defaulting to 1.

interval

The interval used for discretisation; see distcrete.

w

The centering of the interval used for discretisation; see distcrete.

...

Further arguments passed to optim.

Value

The function returns a list with human-readable parametrisation of the discretised Gamma distibution (mean, sd, cv), convergence indicators, and the discretised Gamma distribution itself as a distcrete object (from the distcrete package).

See also

The distcrete package for discretising distributions, and optim for details on available optimisation procedures.

Examples

## generate data mu <- 15.3 # days sigma <- 9.3 # days cv <- mu / sigma cv
#> [1] 1.645161
param <- gamma_mucv2shapescale(mu, cv) if (require(distcrete)) { w <- distcrete("gamma", interval = 1, shape = param$shape, scale = param$scale, w = 0) x <- w$r(100) x fit_disc_gamma(x) }
#> Loading required package: distcrete
#> $mu #> [1] 16.32518 #> #> $cv #> [1] 1.489823 #> #> $sd #> [1] 24.32163 #> #> $ll #> [1] -359.4442 #> #> $converged #> [1] TRUE #> #> $distribution #> A discrete distribution #> name: gamma #> parameters: #> shape: 0.450537383210182 #> scale: 36.2349175631082 #>