lnormPar: Lognormal distribution parameter conversion.

lnormParR Documentation

Lognormal distribution parameter conversion.

Description

lnormPar converts the parameters of lognormal distribution between linear and log scales. Lognormal distribution is naturally characterized by parameters on the log scale. However, the distribution can also be parameterized on the linear scale, e.g. using sample-based parameters estimates. lnormPar accepts either the mean and sd parameters from the linear scale and computes the meanlog and sdlog parameters on the log scale, or meanlog and sdlog parameters from the log scale and computes the mean and sd parameters on the linear scale.

Usage

lnormPar(mean = NULL, 
    sd = NULL, meanlog = NULL, 
    sdlog = NULL)

Arguments

mean

the mean on the linear scale

sd

the standard deviation on the linear scale

meanlog

the mean on the log scale

sdlog

the standard deviation on the log scale

Value

a named list of length 4 holding both the computed parameters and the input paramaters. The parameter names correspond to the names of the arguments, i.e. mean, sd, meanlog, and sdlog. The computed parameters come first in the list.

Author(s)

Tomas Sieger

References

http://www.mathworks.com/help/stats/lognstat.html

Examples

# convert parameters from the linear scale to the log scale
paramsOnLogScale <- lnormPar(mean = 10, sd = 3)
print(paramsOnLogScale)

# convert parameters from the log scale to the linear scale
paramsOnLinearScale <- lnormPar(meanlog = paramsOnLogScale$meanlog, sdlog = paramsOnLogScale$sdlog)
print(paramsOnLinearScale)

# Check the conversion empirically:
# estimate the mean and standard deviation of a sample drawn from the
# lognormal distribution with (log) parameters computed from
# parameters on the linear scale
x<-rlnorm(10000, paramsOnLogScale$meanlog, paramsOnLogScale$sdlog)
print(mean(x))
print(sd(x))

tsieger/tsiMisc documentation built on Oct. 10, 2023, 10:24 p.m.