Learn R Programming

epiparameter (version 0.4.1)

convert_summary_stats_to_params: Convert the summary statistics of a distribution to parameters

Description

Convert the summary statistics for a range of distributions to the distribution's parameters. Most summary statistics are calculated analytically given the parameters. An exception is the Weibull distribution which uses a root finding numerical method.

Usage

convert_summary_stats_to_params(x, ...)

# S3 method for character convert_summary_stats_to_params( x = c("lnorm", "gamma", "weibull", "nbinom", "geom"), ... )

# S3 method for epiparameter convert_summary_stats_to_params(x, ...)

Value

A list of either one or two elements (depending on how many parameters the distribution has).

Arguments

x

An R object.

...

<dynamic-dots> Numeric named summary statistics used to convert to parameter(s). An example is the mean and sd summary statistics for the lognormal (lnorm) distribution.

Details

Summary statistics should be named accordingly (case-sensitive):

  • mean: mean

  • median: median

  • mode: mode

  • variance: var

  • standard deviation: sd

  • coefficient of variation: cv

  • skewness: skewness

  • excess kurtosis: ex_kurtosis

Note: Not all combinations of summary statistics can be converted into distribution parameters. In this case the function will error stating that the parameters cannot be calculated from the given input.

The distribution names and parameter names follow the style of distributions in R, for example the lognormal distribution is lnorm, and its parameters are meanlog and sdlog.

See Also

convert_params_to_summary_stats()

Examples

Run this code
# examples using characters
convert_summary_stats_to_params("lnorm", mean = 1, sd = 1)
convert_summary_stats_to_params("weibull", mean = 2, var = 2)
convert_summary_stats_to_params("geom", mean = 2)

# examples using 
epiparameter <- epiparameter_db(single_epiparameter = TRUE)
convert_summary_stats_to_params(epiparameter)

# example using  and specifying summary stats
epiparameter$summary_stats <- list()
convert_summary_stats_to_params(epiparameter, mean = 10, sd = 2)

Run the code above in your browser using DataLab