Approximating the difference of lognormal random variables

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 \(y_s = 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.

Two uncorrelated random variables

##           mu        sigma        shift 
##   6.14704349   0.06859943 456.07414434
##     mean 
## 12.36042

Several functions accept the shift argument to handle this already.

##          mean     var       cv
## [1,] 12.36042 1035.05 2.602839
##       mu 
## 9.065469
##       mu 
## 11.25952

For the functions from the stats package, the shifting has to be done manually.

A check by random numbers (dotted lines) shows close correspondence.

Test if difference is significantly different from zero

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.

## 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.
## Loading required namespace: mvtnorm
##        pLo    pSample 
## 0.04540137 0.03549000

In the example both approaches give a probability of less than 5% so that we conclude that the difference is significant.

Two positively correlated variables

## Warning in estimateDiffLognormal(mu1, mu2, sigma1, sigma2, corr = corr):
## Expected S0+/S0- << 1 but this ratio was 0.34219239671082. The Lo 2012
## approximation becomes inaccurate for small numbers a and b.
##          mu       sigma       shift 
##   5.1762267   0.1264911 115.3050125
##    mean 
## 63.1304

Check with sampled distribution.

##          [,1]     [,2]
## [1,] 126.5819 67.84677
## [2,] 122.5647 57.59263
## [3,] 146.4594 64.30370
## [4,] 145.0753 60.23750
## [5,] 160.1501 59.00914
## [6,] 168.1679 73.56144

The approximation for the difference of positively correlated random numbers predicts a narrower distribution than with the uncorrelated or negatively correlated difference above. However, this case less accurate and shows some deviations from the sampled distribution around the mode.

Subtracting a variable with larger variance

The method of Lo12 requires \(\sigma_b < \sigma_a\) and otherwise gives an error.

## 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 \(y_r = -y = b - a\) and plot the density of the shifted and negated distribution.

##           mu        sigma        shift 
##   6.10147970   0.06859943 455.64000921
##     mean 
## 8.070146

Because we subtract a large-variance lognormal variable, the distribution becomes right-skewed.