View source: R/extract_param.R
| extract_param | R Documentation |
Summary data of distributions, as provided by reports and meta-analyses, can be used to extract the parameters of a chosen distribution. Currently available distributions are: lognormal, gamma, Weibull and normal. Extracting from a lognormal returns the meanlog and sdlog parameters, extracting from the gamma and Weibull returns the shape and scale parameters, and extracting from the normal returns the mean and sd parameters.
extract_param(
type = c("percentiles", "range"),
values,
distribution = c("lnorm", "gamma", "weibull", "norm"),
percentiles,
samples,
control = list(max_iter = 1000, tolerance = 1e-05)
)
type |
A |
values |
A |
distribution |
A |
percentiles |
A |
samples |
A |
control |
A named list containing options for the optimisation. List
element |
For gamma, lnorm and weibull, extract_param() works only
for strictly positive values at the percentiles of a distribution or the
median and range of data (numerics supplied to the values argument).
This means that negative values at the lower percentile or lower range
will not work with this function although they may present themselves in
epidemiological data (e.g. negative serial interval). For the norm
distribution negative values are allowed.
A named numeric vector with the parameter values of the
distribution. If the distribution = lnorm then the parameters returned are
the meanlog and sdlog; if the distribution = gamma or distribution = weibull then the parameters returned are the shape and scale; if
distribution = norm then the parameters returned are mean and sd.
Adam Kucharski, Joshua W. Lambert
# set seed to control for stochasticity
set.seed(1)
# extract parameters of a lognormal distribution from the 75 percentiles
extract_param(
type = "percentiles",
values = c(6, 13),
distribution = "lnorm",
percentiles = c(0.125, 0.875)
)
# extract parameters of a gamma distribution from median and range
extract_param(
type = "range",
values = c(10, 3, 18),
distribution = "gamma",
samples = 20
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.