lnormPar.RdlnormPar 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.
lnormPar(mean = NULL, sd = NULL, meanlog = NULL, sdlog = NULL)
| 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 |
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.
http://www.mathworks.com/help/stats/lognstat.html
# convert parameters from the linear scale to the log scale paramsOnLogScale <- lnormPar(mean = 10, sd = 3) print(paramsOnLogScale)#> $meanlog #> [1] 2.259496 #> #> $sdlog #> [1] 0.2935604 #> #> $mean #> [1] 10 #> #> $sd #> [1] 3 #># convert parameters from the log scale to the linear scale paramsOnLinearScale <- lnormPar(meanlog = paramsOnLogScale$meanlog, sdlog = paramsOnLogScale$sdlog) print(paramsOnLinearScale)#> $mean #> [1] 10 #> #> $sd #> [1] 3 #> #> $meanlog #> [1] 2.259496 #> #> $sdlog #> [1] 0.2935604 #># 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))#> [1] 9.951941#> [1] 2.963514