Learn R Programming

PDQutils (version 0.1.1)

dapx_gca: Approximate density and distribution via Gram-Charlier A expansion.

Description

Approximate the probability density or cumulative distribution function of a distribution via its raw moments.

Usage

dapx_gca(x, raw.moments, support=c(-Inf,Inf), log=FALSE)

papx_gca(q, raw.moments, support=c(-Inf,Inf), lower.tail=TRUE, log.p=FALSE)

Arguments

x
where to evaluate the approximate density.
raw.moments
an atomic array of the 1st through kth raw moments of the probability distribution.
support
the support of the density function. It is assumed that the density is zero on the complement of this open interval.
log
logical; if TRUE, densities $f$ are given as $\mbox{log}(f)$.
q
where to evaluate the approximate distribution.
log.p
logical; if TRUE, probabilities p are given as $\mbox{log}(p)$.
lower.tail
whether to compute the lower tail. If false, we approximate the survival function.

Value

  • The approximate density at x, or the approximate CDF at q.

Details

Given the raw moments of a probability distribution, we can approximate the probability density function, or the cumulative distribution function, via a Gram-Charlier A expansion on the standardized distribution.

Suppose $f(x)$ is the probability density of some random variable, and let $F(x)$ be the cumulative distribution function. Let $He_j(x)$ be the $j$th probabilist's Hermite polynomial. These polynomials form an orthogonal basis, with respect to the function $w(x)$ of the Hilbert space of functions which are square $w$-weighted integrable. The weighting functimn is $w(x) = e^{-x^2/2} = \sqrt{2\pi}\phi(x)$. The orthogonality relationship is $$\int_{-\infty}^{\infty} He_i(x) He_j(x) w(x) \mathrm{d}x = \sqrt{2\pi} j! \delta_{ij}.$$

Expanding the density $f(x)$ in terms of these polynomials in the usual way (abusing orthogonality) one has $$f(x) = \sum_{0\le j} \frac{He_j(x)}{j!} \phi(x) \int_{-\infty}^{\infty} f(z) He_j(z) \mathrm{d}z.$$ The cumulative distribution function is 'simply' the integral of this expansion. Abusing certain facts regarding the PDF and CDF of the normal distribution and the probabilist's Hermite polynomials, the CDF has the representation $$F(x) = \Phi(x) - \sum_{1\le j} \frac{He_{j-1}(x)}{j!} \phi(x) \int_{-\infty}^{\infty} f(z) He_j(z) \mathrm{d}z.$$

These series contain coefficients defined by the probability distribution under consideration. They take the form $$c_j = \frac{1}{j!}\int_{-\infty}^{\infty} f(z) He_j(z) \mathrm{d}z.$$ Using linearity of the integral, these coefficients are easily computed in terms of the coefficients of the Hermite polynomials and the raw, uncentered moments of the probability distribution under consideration. Note that it may be the case that the computation of these coefficients suffers from bad numerical cancellation for some distributions, and that an alternative formulation may be more numerically robust.

References

Jaschke, Stefan R. "The Cornish-Fisher-expansion in the context of Delta-Gamma-normal approximations." No. 2001, 54. Discussion Papers, Interdisciplinary Research Project 373: Quantification and Simulation of Economic Processes, 2001. http://www.jaschke-net.de/papers/CoFi.pdf

S. Blinnikov and R. Moessner. "Expansions for nearly Gaussian distributions." Astronomy and Astrophysics Supplement 130 (1998): 193-205. http://arxiv.org/abs/astro-ph/9711239

See Also

qapx_cf

Examples

Run this code
# normal distribution:
xvals <- seq(-2,2,length.out=501)
d1 <- dapx_gca(xvals, c(0,1,0,3,0))
d2 <- dnorm(xvals)
d1 - d2

qvals <- seq(-2,2,length.out=501)
p1 <- papx_gca(qvals, c(0,1,0,3,0))
p2 <- pnorm(qvals)
p1 - p2

Run the code above in your browser using DataLab