# PDQ Functions via Gram Charlier, Edgeworth, and Cornish Fisher Approximations

A collection of tools for approximating the 'PDQ' functions (respectively, the cumulative distribution, density, and quantile) of probability distributions via classical expansions involving moments and cumulants.

PDQ Functions via Gram Charlier, Edgeworth, and Cornish Fisher Approximations

-- Steven E. Pav, [email protected]

## Installation

This package may be installed from CRAN; the latest development version may be installed via drat, or built from github:

# Basic Usage

Approximating the distribution of a random variable via the Gram Charlier, Edgeworth, or Cornish Fisher expansions is most convenient when the random variable can be decomposed as the sum of a small number of independent random variables whose cumulants can be computed. For example, suppose $Y = \sum_{1 \le i \le k} \sqrt{X_i / \nu_i}$ where the $X_i$ are independent central chi-square random variables with degrees of freedom $\nu_1,\nu_2,...,\nu_k$. I will call this a 'snak' distribution, for 'sum of Nakagami', since each summand follows a Nakagami distribution. We can easily write code that generates variates from this distribution given a vector of the degrees of freedom:

Let's take one hundred thousand draws from this distribution and see whether it is approximately normal, by performing a q-q plot against a normal distribution.

While this is very nearly normal, we can get a better approximation. Using the additivity property of cumulants, we can compute the cumulants of $Y$ easily if we have the cumulants of the $X_i$. These in turn can be computed from the raw moments. See wikipedia for the raw moments of the Chi distribution. The following function computes the cumulants:

We can now implement the 'dpq' functions trivially using the Edgeworth and Cornish Fisher approximations, as follows:

The density and distribution functions could also have been implemented via the Gram Charlier expansion, although there seems to be little justification for so doing, as the Edgeworth expansion is often a better approximation.

The q-q plot looks better now:

Note that the q-q plot uses the approximate quantile function, qsnak. If we compute the approximate CDF of the random draws, we hope it will be nearly uniform, and indeed it is:

# Edgeworth versus Gram Charlier

Blinnikov and Moessner note that the Gram Charlier expansion will actually diverge for some distributions when more terms in the expansion are considered, behaviour which is not seen for the Edgeworth expansion. We will consider the case of a chi-square distribution with 5 degrees of freedom. The 2 and 6 term Gram Charlier expansions are shown, along with the true value of the PDF, replicating figure 1 of Blinnikov and Moessner:

Compare this with the 2 and 4 term Edgeworth expansions, replicating figure 6 of Blinnikov and Moessner:

# Rearranging for monotonicity

In one of a series of papers, Chernozhukov et. al. demonstrate the use of monotonic rearrangements in Edgeworth and Cornish-Fisher expansions of the CDF and quantile functions, which are, by definition, non-decreasing. It is shown that monotone rearrangement reduces the error of an initial approximation. This is easy enough to code with tools readily available in R. First, let us compute the 8 term Gram Charlier approximation to the CDF of the Chi-square with 5 degrees of freedom. This should display non-monotonicity. Then we compute the monotonic rearrangement:

# Reference manual

install.packages("PDQutils")

0.1.6 by Steven E. Pav, 4 years ago

https://github.com/shabbychef/PDQutils

Report a bug at https://github.com/shabbychef/PDQutils/issues

Browse source code at https://github.com/cran/PDQutils

Authors: Steven E. Pav [aut, cre]

Documentation:   PDF Manual