# getParmsLognormForModeAndUpper: Calculate mu and sigma of lognormal from summary statistics. In lognorm: Functions for the Lognormal Distribution

## Description

Calculate mu and sigma of lognormal from summary statistics.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```getParmsLognormForMedianAndUpper(median, upper, sigmaFac = qnorm(0.99)) getParmsLognormForMeanAndUpper(mean, upper, sigmaFac = qnorm(0.99)) getParmsLognormForLowerAndUpper(lower, upper, sigmaFac = qnorm(0.99)) getParmsLognormForLowerAndUpperLog(lowerLog, upperLog, sigmaFac = qnorm(0.99)) getParmsLognormForModeAndUpper(mle, upper, sigmaFac = qnorm(0.99)) getParmsLognormForMoments(mean, var, sigmaOrig = sqrt(var)) getParmsLognormForExpval(mean, sigmaStar) ```

## Arguments

 `median` geometric mu (median at the original exponential scale) `upper` numeric vector: value at the upper quantile, i.e. practical maximum `sigmaFac` sigmaFac=2 is 95% sigmaFac=2.6 is 99% interval. `mean` expected value at original scale `lower` value at the lower quantile, i.e. practical minimum `lowerLog` value at the lower quantile, i.e. practical minimum at log scale `upperLog` value at the upper quantile, i.e. practical maximum at log scale `mle` numeric vector: mode at the original scale `var` variance at original scale `sigmaOrig` standard deviation at original scale `sigmaStar` multiplicative standard deviation

## Details

For `getParmsLognormForMeanAndUpper` there are two valid solutions, and the one with lower sigma , i.e. the not so strongly skewed solution is returned.

## Value

numeric matrix with columns 'mu' and 'sigma', the parameter of the lognormal distribution. Rows correspond to rows of inputs.

## Functions

• `getParmsLognormForMedianAndUpper`: Calculates mu and sigma of lognormal from median and upper quantile.

• `getParmsLognormForMeanAndUpper`: Calculates mu and sigma of lognormal from mean and upper quantile.

• `getParmsLognormForLowerAndUpper`: Calculates mu and sigma of lognormal from lower and upper quantile.

• `getParmsLognormForLowerAndUpperLog`: Calculates mu and sigma of lognormal from lower and upper quantile at log scale.

• `getParmsLognormForModeAndUpper`: Calculates mu and sigma of lognormal from mode and upper quantile.

• `getParmsLognormForMoments`: Calculate mu and sigma from moments (mean anc variance)

• `getParmsLognormForExpval`: Calculate mu and sigma from expected value and geometric standard deviation

## References

```Limpert E, Stahel W & Abbt M (2001) Log-normal Distributions across the Sciences: Keys and Clues. Oxford University Press (OUP) 51, 341, 10.1641/0006-3568(2001)051[0341:lndats]2.0.co;2```

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43``` ```# example 1: a distribution with mode 1 and upper bound 5 (thetaEst <- getParmsLognormForModeAndUpper(1,5)) mle <- exp(thetaEst - thetaEst^2) all.equal(mle, 1, check.attributes = FALSE) # plot the distributions xGrid = seq(0,8, length.out = 81)[-1] dxEst <- dlnorm(xGrid, meanlog = thetaEst, sdlog = thetaEst) plot( dxEst~xGrid, type = "l",xlab = "x",ylab = "density") abline(v = c(1,5),col = "gray") # example 2: true parameters, which should be rediscovered theta0 <- c(mu = 1, sigma = 0.4) mle <- exp(theta0 - theta0^2) perc <- 0.975 # some upper percentile, proxy for an upper bound upper <- qlnorm(perc, meanlog = theta0, sdlog = theta0) (thetaEst <- getParmsLognormForModeAndUpper( mle,upper = upper,sigmaFac = qnorm(perc)) ) #plot the true and the rediscovered distributions xGrid = seq(0,10, length.out = 81)[-1] dx <- dlnorm(xGrid, meanlog = theta0, sdlog = theta0) dxEst <- dlnorm(xGrid, meanlog = thetaEst, sdlog = thetaEst) plot( dx~xGrid, type = "l") #plot( dx~xGrid, type = "n") #overplots the original, coincide lines( dxEst ~ xGrid, col = "red", lty = "dashed") # example 3: explore varying the uncertainty (the upper quantile) x <- seq(0.01,1.2,by = 0.01) mle = 0.2 dx <- sapply(mle*2:8,function(q99){ theta = getParmsLognormForModeAndUpper(mle,q99,qnorm(0.99)) #dx <- dDistr(x,theta[,"mu"],theta[,"sigma"],trans = "lognorm") dx <- dlnorm(x,theta[,"mu"],theta[,"sigma"]) }) matplot(x,dx,type = "l") # Calculate mu and sigma from expected value and geometric standard deviation .mean <- 1 .sigmaStar <- c(1.3,2) (parms <- getParmsLognormForExpval(.mean, .sigmaStar)) # multiplicative standard deviation must equal the specified value cbind(exp(parms[,"sigma"]), .sigmaStar) ```

lognorm documentation built on Nov. 22, 2021, 1:07 a.m.