Lo 2012 reports an approximation for the difference of two random variables by a shifted lognormal distribution.
Rather than approximating the density of y = a − b, it approximates the density of ys = a − b + s, where s is the shift. Hence, one has to subtract s from provided mean and quantiles. One can can use the variance, and relative error but has to recompute the relative error.
The probability of the zero quantile needs to be larger than a significance level. We can compute it based on the lognormal approximation.
Since Lo12 is only accurate if the expected difference is small compared to the expected sum, the probability of the difference being larger than zero can be estimated by a sampling both terms.
mu1 = log(120)
mu2 = log(60)
sigma1 = 0.25
sigma2 = 0.15
coefDiff <- estimateDiffLognormal( mu1,mu2,sigma1,sigma2, corr = -0.8 )
## Warning in estimateDiffLognormal(mu1, mu2, sigma1, sigma2, corr = -0.8):
## Expected S0+/S0- << 1 but this ratio was 0.34219239671082. The Lo 2012
## approximation becomes inaccurate for small numbers a and b.
pLo <- plnorm(0 + coefDiff["shift"], coefDiff["mu"], coefDiff["sigma"])
pSample <- pDiffLognormalSample(mu1,mu2,sigma1,sigma2, corr = -0.8)
## Loading required namespace: mvtnorm
## pLo pSample
## 0.04540137 0.03412000
In the example both approaches give a probability of less than 5% so that we conclude that the difference is significant.
The method of Lo12 requires σb < σa and otherwise gives an error.
# generate nSample values of two lognormal random variables
mu1 = log(110)
mu2 = log(100)
sigma1 = 0.15
sigma2 = 0.25
try(coefDiff <- estimateDiffLognormal(mu1,mu2, sigma1,sigma2, 0))
## Error in estimateDiffLognormal(mu1, mu2, sigma1, sigma2, 0) :
## expected sigma_a > sigma_b but got 0.15 <= 0.25. Exchange the terms and negate the resulting quantiles (see vignette('lognormalDiff').
But one can compute the density of yr = −y = b − a and plot the density of the shifted and negated distribution.
# note the switch of positions of mu1 and mu2: mu2 - mu1
#(coefDiff <- estimateDiffLognormal(mu1,mu2, sigma1,sigma2, 0)
(coefDiff <- estimateDiffLognormal(mu2,mu1, sigma2,sigma1, 0))
## mu sigma shift
## 6.10147970 0.06859943 455.64000921
# note the minus sign in front
(expDiff <- -(getLognormMoments(
coefDiff["mu"], coefDiff["sigma"], shift = coefDiff["shift"])[,"mean"]))
## mean
## 8.070146
p <- seq(0,1,length.out = 100)[-c(1,100)]
dsPredY <- data.frame(
var = "y",
q_shifted_neg = qlnorm(p, coefDiff["mu"], coefDiff["sigma"] )
) %>%
mutate(
# note the minus sign in front
q = -(q_shifted_neg - coefDiff["shift"]),
d = dlnorm(q_shifted_neg, coefDiff["mu"], coefDiff["sigma"])
)
Because we subtract a large-variance lognormal variable, the distribution becomes right-skewed.