Lee and Lin's Algorithm AS269 for higher order Cornish Fisher quantile approximation.
1 
z 
the quantiles of the normal distribution. an atomic vector. 
cumul 
the standardized cumulants of order 3, 4, ..., k. an atomic vector. 
order.max 
the maximum order approximation, must be greater than

all.ords 
a logical value. If 
The Cornish Fisher approximation is the Legendre inversion of the Edgeworth expansion of a distribution, but ordered in a way that is convenient when used on the mean of a number of independent draws of a random variable.
Suppose x_1, x_2, ..., x_n are n independent draws from some probability distribution. Letting
X = (x_1 + x_2 + ... x_n) / sqrt(n),
the Central Limit Theorem assures us that, assuming finite variance,
X ~~ N(sqrt(n) mu, sigma),
with convergence in n.
The Cornish Fisher approximation gives a more detailed picture of the quantiles of X, one that is arranged in decreasing powers of sqrt(n). The quantile function is the function q(p) such that P(x <= q(p)) = p. The Cornish Fisher expansion is
q(p) = sqrt{n}mu + sigma (z + sum_{3 <= j} c_j f_j(z)),
where z = qnorm(p), and c_j involves standardized cumulants of the distribution of x_i of order up to j. Moreover, the c_j include decreasing powers of sqrt(n), giving some justification for truncation. When n=1, however, the ordering is somewhat arbitrary.
A matrix, which is, depending on all.ords
, either with one column per
order of the approximation, or a single column giving the maximum order
approximation. There is one row per value in z
.
Invalid arguments will result in return value NaN
with a warning.
A warning will be thrown if any of the z are greater than 3.719017274 in absolute value; the traditional AS269 errors out in this case.
Steven E. Pav shabbychef@gmail.com
Lee, YS., and Lin, TK. "Algorithm AS269: High Order Cornish Fisher Expansion." Appl. Stat. 41, no. 1 (1992): 233240. http://www.jstor.org/stable/2347649
Lee, YS., and Lin, TK. "Correction to Algorithm AS269: High Order Cornish Fisher Expansion." Appl. Stat. 42, no. 1 (1993): 268269. http://www.jstor.org/stable/2347433
AS 269. http://lib.stat.cmu.edu/apstat/269
Jaschke, Stefan R. "The CornishFisherexpansion in the context of DeltaGammanormal approximations." No. 2001, 54. Discussion Papers, Interdisciplinary Research Project 373: Quantification and Simulation of Economic Processes, 2001. http://www.jaschkenet.de/papers/CoFi.pdf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  foo < AS269(seq(2,2,0.01),c(0,2,0,4))
# test with the normal distribution:
s.cumul < c(0,0,0,0,0,0,0,0,0)
pv < seq(0.001,0.999,0.001)
zv < qnorm(pv)
apq < AS269(zv,s.cumul,all.ords=FALSE)
err < zv  apq
# test with the exponential distribution
rate < 0.7
n < 18
# these are 'raw' cumulants'
cumul < (rate ^ (1:n)) * factorial(0:(n1))
# standardize and chop
s.cumul < cumul[3:length(cumul)] / (cumul[2]^((3:length(cumul))/2))
pv < seq(0.001,0.999,0.001)
zv < qnorm(pv)
apq < cumul[1] + sqrt(cumul[2]) * AS269(zv,s.cumul,all.ords=TRUE)
truq < qexp(pv, rate=rate)
err < truq  apq
colSums(abs(err))
# an example from Wikipedia page on CF,
# \url{https://en.wikipedia.org/wiki/Cornish%E2%80%93Fisher_expansion}
s.cumul < c(5,2)
apq < 10 + sqrt(25) * AS269(qnorm(0.95),s.cumul,all.ords=TRUE)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.