[R] Gram-Charlier CDF

Tolga Uzuner tolga at coubros.com
Sun Feb 12 22:38:22 CET 2006


Hi there,

Does anyone have something better (read faster) than the following for 
the CDF of an A-type Gram-Charlier expansion ?

Many thanks in advance,
Tolga



fact <- function (x) gamma(1 + x)

gc <- function(w,skew=0,kurtosis=0)
# gram-charlier density
# to be positive, must respect the constraints:
# [-1.0493,1.0493] and [3,7] respectively
{
sapply(w,function(y)
dnorm(y)-
skew/fact(3)*drv(dnorm,y,3)+
kurtosis/fact(4)*drv(dnorm,y,4))
}

gcd <-function(w,skew=0,kurtosis=0)
# gram-charlier cdf
integrate(function(x) gc(x,skew,kurtosis),-Inf,w)$value




More information about the R-help mailing list