The objective is to parametrize a lognormal distribution, which should then have a given mean and a given value for a given percentile.
1 Answer
Let $\mu$ and $\sigma$ be parameters of the corresponding Normal distribution (its mean and standard deviation, respectively). Given the lognormal mean $m$ and the value $z$ for percentile $\alpha$, we need to find $\mu$ and $\sigma \gt 0$.
To this end, let $\Phi$ be the standard Normal distribution function. The two pieces of information are
$m = \exp(\mu + \sigma^2/2)$, whence $\mu + \sigma^2/2 = \log(m)$.
$\log(z) = \mu + \sigma \Phi^{-1}(\alpha).$
Subtracting the second from the first and multiplying by $2$ produces
$$\sigma^2 - 2\Phi^{-1}(\alpha)\sigma + 2(\log(z) - \log(m)) = 0.$$
This is a quadratic equation in $\sigma$, solved with the usual Quadratic Formula. There will be zero, one, or two solutions. Two solutions are likely to occur when $\alpha$ is close to $1$.
$\mu$ is then found in terms of $\sigma$ by using either of the original equations; for instance,
$$\mu = \log(m) - \sigma^2/2$$
will do nicely.
(A special case is when $\alpha=1/2$, corresponding to the median, where $\Phi^{-1}(\alpha) = 0$. The formula for $\sigma$ simplifies to $$\sigma^2 + 2(\log(z) - \log(m)) = 0.$$ That is the solution obtained by @Glen_b at Can I get the parameters of a lognormal distribution from the sample mean & median?, which uses "$\tilde{m}$" for "$z$".)
For fitting these estimates to data, consider measuring the goodness of fit for discriminating between two solutions when they are available. A $\chi^2$ statistic should do fine. This approach is illustrated in the following R
code, which simulates data, performs the analysis, draws a histogram of the data, and overplots the solutions. When a solution fits poorly, its plot is faded out. Here is an example.
#
# Given a mean `m` and `alpha` quantile `z, find the matching parameters of any
# lognormal distributions.
#
f <- function(m, z, alpha) {
B <- -2 * qnorm(alpha)
C <- 2*(log(z) - log(m))
sigma <- (-B + c(-1,1)*sqrt(B^2 - 4*C)) / 2
sigma <- sigma[sigma > 0 & !is.na(sigma)]
mu <- log(m) - sigma^2 / 2
return(cbind(mu=mu, sigma=sigma))
}
#
# Compute a chi-squared statistic for data `x` corresponding to binning
# a lognormal distribution with parameter `theta` into `n` equal-size bins.
#
chi.squared <- function(theta, x, n=4) {
cutpoints <- exp(qnorm(seq(0, 1, length.out=n+1), theta[1], theta[2]))
counts <- table(cut(x, cutpoints))
expected <- length(x) / n
stat <- sum((counts - expected)^2 / expected)
}
#
# Simulate data, compute their statistics, and estimate matching lognormal
# distributions.
#
set.seed(17)
x <- exp(rnorm(20, sd=0.4))
m <- mean(x)
alpha <- 0.9
z <- quantile(x, alpha)
theta <- f(m, z, alpha)
stats <- apply(theta, 1, chi.squared, x=x)
#
# Plot the data and any matching lognormal density functions.
#
hist(x, freq=FALSE, breaks=12)
col <- "Red"
invisible(apply(theta, 1, function(q) {
stat <- chi.squared(q, x, min(length(x), 5))
curve(dnorm(log(x), q["mu"], q["sigma"])/x, add=TRUE, lwd=2,
col=hsv(0, min(1, 2/sqrt(1 + 10*stat/length(x))), 0.9))
}))