1

The lognormal density function is usually plotted on a linear x axis. I find it useful to visualize the lognormal density on a logarithmic x axis (for example when choosing a lognormal prior in a Bayesian model). To do so, initially I would simply take the log of the x axis and plot the density, but I soon realized that this didn't look right (the median on the linear x axis plot wouldn't match the mean on the log x axis plot). After some study I realized that changing the coordinates is equivalent to transforming the random variable, and I needed to scale the lognormal density by a factor of $x$ in order to plot it on a logarithmic x axis as shown in the graph below:

meanlog = 0; sdlog = 1
par(mfrow=c(1,2))
xlim = c(qlnorm(0.001, meanlog=meanlog, sdlog=sdlog), 
         qlnorm(0.999, meanlog=meanlog, sdlog=sdlog))
x = seq(xlim[1], xlim[2], length.out=10000)
y = dlnorm(x, meanlog=meanlog, sdlog=sdlog)
plot(x, y, type="l", xlab="x", ylab="Density", 
     main="Linear x axis")
abline(v=exp(meanlog)); text(exp(meanlog)+1.8, 0.405, "Median")

plot(log(x), y*x, type='l', xlab="x", ylab="Density", xaxt="n", 
     main="Logarithmic x axis")
abline(v=meanlog); text(meanlog+0.5, 0.405, "Median")
lims = par("usr")[1:2]; base = exp(1)
lims = base^lims    
minPow = floor(log10(lims[1]));  maxPow = ceiling(log10(lims[2]))
powSeq = seq(minPow, maxPow);  axSeq = 10^powSeq
axis(1, at=log(axSeq, base=base), labels=as.character(axSeq))
for (i in 1:length(axSeq)){
   bb = (1:10)/10; a = (bb*10^powSeq[i]);   
   axis(1, at=log(a, base=base), tcl=-0.25, labels=F)
}

enter image description here

The rationale for the scaling factor is provided below:

Suppose that $W$ is lognormally distributed, and $X = \ln(W)$, so $e^X = W$. The distribution function of $X$ is:

$F_X(x) = P(X \le x) = P (X \le \ln(w)) = P(e^X \le w) = P(W \le w) = L_X(e^x)$

where $L_X(x)$ is the lognormal distribution function. The density function of $X$ can be obtained by differentiating its distribution function:

$f_X(x) = \frac{d}{dx} L_X(e^x) = e^x l_X(e^x) = w l_X(w)$

where $l_X(x)$ is the lognormal density function.

Although I'm fairly confident that the arguments above are correct I'm not a statistician or mathematician, and I would appreciate if more qualified users could either confirm them or correct them.

sam81
  • 171
  • 6
  • 2
    Yes, lognormal distribution is the normal distribution of the log scaled variable. It's pretty much a [definition](https://en.wikipedia.org/wiki/Log-normal_distribution). – Aksakal Apr 18 '17 at 13:52
  • See the chart [here](https://commons.wikimedia.org/wiki/File:Lognormal_Distribution.svg#/media/File:Lognormal_Distribution.svg) – Aksakal Apr 18 '17 at 14:01
  • Thanks for confirming, it may be elementary for statisticians but at first it wasn't very intuitive for me that simply changing the coordinates of the plot would require scaling the density as well. – sam81 Apr 18 '17 at 14:02
  • Intuition is simple: think of a density of a water. It's 1 kg/litre. If you change the scale of the volume from litres to millitres but keep the density at 1, would it make a sense? No, you have to scale it as 0.001 kg/mlitres or 1 milligram/millilitres. – Aksakal Apr 18 '17 at 14:06
  • @Aksakal I am not clear that multiplying or dividing by constants provides *any* intuition for going back and forth between logarithmic scales and their exponentiated relatives! – Nick Cox Apr 18 '17 at 15:14
  • @NickCox, it's the same thing to me. The only difference is that in one case the transformation is linear. – Aksakal Apr 18 '17 at 15:44
  • 1
    @Aksakal Sorry, friendly disagreement still. OK, nonlinear is just like linear except in so far as it isn't. True, but not helpful at the level needed. I don't think you can give intuition on logarithms that way. I see no scope for explanation of lognormal (or even a little intuitve help) without logarithms any more than there's chocolate cake without chocolate. – Nick Cox Apr 18 '17 at 15:57
  • The basic intuition (and recapitulation of the algebra) is covered at the indicated duplicate (even though the transformation is going the other way, the issue should be clear enough from that I hope). See also the comments under the answer [here](https://stats.stackexchange.com/questions/100017/why-do-the-normal-and-log-normal-density-functions-differ-by-a-factor/100040#100040). If there's something not covered by those please edit to focus more precisely on what else you require (or post a new one which focuses on the remaining issues) – Glen_b Apr 19 '17 at 05:43

0 Answers0