Description Usage Arguments Details Value Functions Examples
Estimate lognormal distribution parameters from a sample
1 2 3 | estimateParmsLognormFromSample(x, na.rm = FALSE)
estimateStdErrParms(x, na.rm = FALSE)
|
x |
numeric vector of sampled values |
na.rm |
a logical value indicating whether NA values should be stripped before the computation proceeds. |
The expected value of a can be determined with higher accuracy the larger the sample. Here, the uncorrelated assumption is applied at the log scale and distribution parameters are returned with the same expected value as the sample, but with uncertainty (sigma) decreased by sqrt(nfin - 1).
Since with low relative error, the lognormal becomes very close to the normal distribution, the distribution of the mean can be well approximated by a normal with sd(mean(x)) ~ sd(x)/sqrt(n-1).
numeric vector with components mu
and sigma
,
i.e., the center parameter (mean at log scale, log(median)) and
the scale parameter (standard deviation at log scale)
estimateParmsLognormFromSample
: Estimate lognormal distribution parameters from a sample
estimateStdErrParms
: Estimate parameters of the lognormal distribution of the mean from an uncorrelated sample
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | .mu <- log(1)
.sigma <- log(2)
n = 200
x <- exp(rnorm(n, mean = .mu, sd = .sigma))
exp(pL <- estimateParmsLognormFromSample(x)) # median and multiplicative stddev
c(mean(x), meanx <- getLognormMoments(pL["mu"],pL["sigma"])[,"mean"])
c(sd(x), sdx <- sqrt(getLognormMoments(pL["mu"],pL["sigma"])[,"var"]))
# stddev decreases (each sample about 0.9) to about 0.07
# for the mean with n replicated samples
se <- estimateStdErrParms(x)
sqrt(getLognormMoments(se["mu"],se["sigma"])[,"var"])
sd(x)/sqrt(n-1) # well approximated by normal
# expected value stays the same
c(meanx, getLognormMoments(se["mu"],se["sigma"])[,"mean"])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.