The Cornish-Fisher approximation to quantiles

0

The Cornish-Fisher (C-F) expansion approximates the quantiles of an arbitrary continuous univariate distribution by using only the mean, variance, skewness, and excess kurtosis of the distribution. Intuitively, you can model the shape of many common probability distributions by using these four moment-based quantities.

This article shows how to use SAS to implement the Cornish-Fisher approximation to a quantile.

The Cornish-Fisher expansion

Let F be a continuous cumulative probability distribution. If p in (0,1) is any probability, then the quantile for p is the value, qp, such that p = F(qp). This is often denoted as qp = F-1(p). For a wide range of distributions, the C-F expansion enables you to approximate the quantile for any probability, p. The approximation is best when p is not too close to 0 or 1.

The C-F expansion is based on a transformation of a normal distribution. The full Cornish-Fisher expansion is an infinite series, but most practitioners truncate the series after four terms. Thus, in the remainder of this article, "the C-F expansion" always means "the four-term C-F expansion."

Let z = Φ-1(p) be the quantile of p for the standard normal distribution. The four-term C-F expansion is the cubic polynomial
q = z + (γ1 / 6)(z2 − 1) + (γ2 / 24)(z3 − 3z) − (γ12 / 36)(2z3 − 5z)
where γ1 is the skewness of the distribution, and γ2 is the excess kurtosis. This function maps the standard normal quantile into a quantile for a standardized distribution whose skewness and excess kurtosis are close to γ1 and γ2, respectively. Notice that the normal distribution has γ1 = γ2 = 0, so the C-F expansion reduces to the identity transformation for the normal distribution itself.

A standardized distribution has zero mean and unit variance. You can use the linear transformation
q → μ + σ q
to adjust the quantile for non-standardized distributions that have mean μ and standard deviation σ.

Implement the Cornish-Fisher expansion in SAS

To demonstrate the C-F expansion, let's use the Gamma distribution with shape parameter equal to 2 and unit scale. The PDF of this distribution is shown to the right. You can see that it does not look very much like a normal distribution. The Wikipedia article about the Gamma distribution contains formulas for the four moments in terms of the shape parameter, α. The mean and variance are both equal to α. The kurtosis is 2/sqrt(α); the excess kurtosis is 6 / α. Thus, when α = 2, the skewness is sqrt(2) ≈ 1.41, and the excess kurtosis is 3.

The following SAS IML program defines a helper function that returns the mean, variance, skewness, and excess kurtosis of the Gamma(α) distribution in terms of the shape parameter. The program then defines a function that evaluates the four-term Cornish-Fisher approximation to the quantiles of the Gamma(α) distribution. The function implements the cubic polynomial formula in the previous section. You can call the function for a vector of probabilities in (0,1) and compare the approximate C-F values with the true values by using the built-in QUANTILE function in Base SAS, as follows:

proc iml;
/* function that computes the mean, variance, skewness, and 
   excess kurtosis for the Gamma distribution */
start Moments_Gamma(Name, param);
   if ksubstr(upcase(Name), 1, 3)="VAR" then 
      return( param );
   if ksubstr(upcase(Name), 1, 4)="MEAN" then 
      return( param );
   if ksubstr(upcase(Name), 1, 4)="SKEW" then 
      return( 2 / sqrt(param) );
   if ksubstr(upcase(Name), 1, 4)="KURT" |
      ksubstr(upcase(Name), 1, 4)="EXKU" then 
      return( 6 / param );
finish;
 
/* Cornish-Fisher expansion for the Gamma(shape) distribution
   p is a vector of probabilities in (0, 1).
   The function returns a vector q, such that 
   q[i] is an approximation to quantile("Gamma", p[i], shape) */
start Cornish_Expand_Gamma(p, shape);
  /* get moments of the distribution: mean, variance, skewness, Ex kurtosis  */
  mu  = Moments_Gamma("Mean", shape);
  var = Moments_Gamma("Var", shape);
  g1 = Moments_Gamma("Skew", shape);
  g2 = Moments_Gamma("ExKurt", shape);
 
  /* Use the 4-term Cornish-Fisher expansion to estimate q for a 
     standardized distribution with those moments */
  z = quantile("Normal", p);    /* z is the standard normal quantile */
  q_std = z + (z##2 - 1)#g1/6 + z#(z##2 - 3)#g2/24 - z#(2#z##2 - 5)#g1##2/36;
  return( mu + sqrt(var) # q_std );  /* incorporate the center and scale */
finish;
 
/* Compare exact quantiles and C-F expansion for the Gamma(2) distribution */
shape = 2;
 
/* Calculate approximate and exact quantiles */
p = T(do(0.01, 0.99, 0.01));
Approx_Q = Cornish_Expand_Gamma(p, shape);
Exact_Q = quantile("Gamma", p, shape);

The following statements overlay the C-F approximation and the true quantile function on a single graph:

/* Prepare data for plotting */
run WideToLong(Probability, Quantile, Method, 
               Approx_Q || Exact_Q, p, {"CF_Approx" "Exact_Gamma"});
 
title "Cornish-Fisher Approximation vs Exact Gamma Quantiles";
title2 "Gamma Distribution (Shape=2)";
call series(Probability, Quantile) group=Method grid={x y};

Wow! That's a good approximation! The C-F expansion is excellent approximation for all but very extreme values of the probability, p.

If you subtract the two curves, you can visualize the absolute difference between the true value and the C-F approximation. The difference is shown in the following graph. The difference is largest for extreme values of the probability, but the overall agreement is remarkably good.

/* plot the difference */
title "Difference Between Exact Quantiles and C-F Approximation";
title2 "Gamma Distribution (Shape=2)";
Difference = Exact_Q - Approx_Q;
call series(p, Difference) grid={x y} label={"Probability" "Difference (Exact-Approx)"}
                           other="refline 0 / axis=y;";

How good is the approximation for other parameter values?

You can change the value of the 'alpha' parameter and rerun the program to determine how the approximation varies with the shape parameter. Try these other values:

  • alpha = 1: For this parameter, the Gamma(1) distribution is equal to the exponential distribution. The exponential distribution is far from being normally distributed. Nevertheless, the cubic transformation of the normal quantiles is close to the actual exponential quantiles except for extreme probabilities. For p = 0.01, the C-F approximation is within 0.24 units of the true quantile.
  • alpha = 4: As alpha increases, the Gamma(alpha) distribution looks more and more normal. For alpha = 4, the C-F approximation is within 0.05 units of the true quantile on the interval (0.01, 0.99).

Why is the C-F expansion useful?

Since we can use the QUANTILE function to compute the exact value of the quantiles of the Gamma distribution, why do we need the C-F approximation?

For any function that is supported by the QUANTILE function in SAS, you do not need to use an approximation. However, you might need to compute the quantiles for a distribution that is not natively supported by the QUANTILE function. For most distributions, the CDF function cannot be explicitly inverted. Thus, to find a quantile, you must solve for the root of a nonlinear equation of the form CDF(q) - p = 0. This requires some sort of root-finding algorithm.

In the past, I have used the FROOT function in IML to solve for the root. The FROOT function requires that you specify an interval that contains the root. This might be a challenge. An alternative is to use Newton's method to find the root. Newton's method requires an approximate guess for the location of a root, which can also be challenging. Fortunately, the Cornish-Fisher approximation provides the required guess. In many cases, the C-F approximation is close enough that Newton's Method converges in 1-3 iterations. This rapid convergence is important when the CDF is expensive to compute, such as when the CDF must be computed by integrating the PDF function.

How to use the C-F expansion for a different distribution

It is straightforward to compute the C-F expansion for a different distribution. You first write a new helper function that returns the mean, variance, skewness, and excess kurtosis for the distribution. (Check Wikipedia or a textbook.) You then modify the Cornish_Expand_Gamma function to call the new function. I will demonstrate this in a subsequent article.

Summary

This article shows how to use the four-term Cornish-Fisher expansion to obtain an approximation for a quantile of a large variety of continuous probability distributions. The C-F formula uses the first four moments of the distribution (mean, variance, skewness, and excess kurtosis) to transform a standard normal quantile. While in theory, this method is limited to distributions that are not "too far from normal," in practice the 4-term CF expansion is very accurate, even for a distribution that is not close to being normal.

The C-F approximation is useful when there is not an explicit formula for the quantile function. In those cases, the C-F approximation provides an initial guess for a root-finding algorithm that solves for the quantile of the distribution. In a future article, I will show how to use the Cornish-Fisher transformation to compute the quantiles of the skew-normal distribution.

The C-F approximation does have limitations, which is discussed in the Appendix.

Appendix

An early effort of Fisher and his colleagues was to describe all distribution in terms of their moments. This effort can be summarized in the moment-ratio (MR) diagram, which organizes many common standardized distributions according to their skewness and kurtosis.

The Cornish-Fisher expansion is not valid if a distribution has an extreme value of skewness and kurtosis. In "A User’s Guide to the Cornish Fisher Expansion" (2014, 2018), Didier Maillard derives the algebraic boundaries where the expansion is valid. If you overlay that region on a moment-ratio diagram, you can visualize the distributions that are not "too far from normal" as measured by the C-F expansion. And, of course, the method assumes that the first four moments exist, which excludes heavy-tailed distributions such as the Cauchy distribution.

In addition, the C-F expansion might not respect the natural boundaries of a distribution. For example, it might predict a negative quantile for a strictly positive distribution when p is very small.

The idea of using power transformations of a normal variable has been used by Fleishman (1978) and Headrick (2002, 2010) to develop flexible families of distributions. Fleishman used cubic transformations whereas Headrick used higher-order polynomials. Both the Fleishman and Headrick systems have limitations in the sense that they cannot model distributions that have extreme skewness and kurtosis.

The "solution" to this problem was found by Johnson (1949) who used non-polynomial transformations of normal variables to construct a flexible system of distributions that covers the entire moment-ratio diagram. The so-called Johnson system of distributions is a marvelous tool. It is supported in SAS by using PROC SIMSYSTEM.

Share

About Author

Rick Wicklin

Distinguished Researcher in Computational Statistics

Rick Wicklin, PhD, is a distinguished researcher in computational statistics at SAS and is a principal developer of SAS/IML software. His areas of expertise include computational statistics, simulation, statistical graphics, and modern methods in statistical data analysis. Rick is author of the books Statistical Programming with SAS/IML Software and Simulating Data with SAS.

Leave A Reply