Ok I switched to the slow loop since it is more obvious what's happening
there.
I am not sure if it is possible to implement it in such a way. Any comments
are highly appreciated!
#
------------------------------------------------------------------------------
# load fGarch and a data set
#
------------------------------------------------------------------------------

library(fGarch)
data(dem2gbp)
x <- dem2gbp[,1]

llhGARCHSK11N <- function(par, x)
{
    mu <- par[1]; omega <- par[2]; alpha <- par[3]; beta <- par[4]
    gamma0<- par[5];
    gamma1<- par[6];
    gamma2<- par[7];
    delta0<- par[8];
    delta1<- par[9];
    delta2<- par[10];
    e <- x - mu
    e2 <- e^2

#Skewness
    sk <- ((x - mu)^3) / length(x)/ sd(x)^3
#Kurtosis
    ku <- (((x - mu)^4) / length(x))/ sd(x)^4 - 3

    ##       slow loop variance
            s2 = omega + alpha*mean(e2) + beta*mean(e2)
            for ( t in 2:length(x))
                s2[t] = omega + alpha*e2[t-1] + beta*s2[t-1]

  eta=e/s2

    ## slow loop skewness
                sk = gamma0 + gamma1*mean(sk) + gamma2 * mean(sk)
            for ( t in 2:length(x))
                sk[t] = gamma0 + gamma1*sk[t-1]^3 + gamma2*sk[t-1]

    ## slow loop kurtosis
                ku = delta0 + delta1*mean(ku) + delta2*mean(ku)
            for ( t in 2:length(x))
                ku[t] = delta0 + delta1*ku[t-1]^4 + delta2*ku[t-1]

 #-sum(log(dnorm(e, mean = 0, sd = sqrt(abs(s2)))))
 -sum(log(1+(sk/6)*(eta^3-3*eta)+((ku-3)/24)*(eta^4-6*eta^2+3))^2-log(1+((sk^2)/6)+(ku-3)^2/24))
}
mu <- mean(x); omega <- 0.1*var(x); alpha <- 0.1; beta <- 0.8
gamma0<- 0;
    gamma1<- 0;
    gamma2<- 0;
    delta0<- 0;
    delta1<- 0;
    delta2<- 0;
parN <- c(mu, omega, alpha, beta, gamma0, gamma1, gamma2 , delta0, delta1,
delta2)
llhGARCHSK11N(parN, x)

small <- 1e-6
lowN <- c(-10*abs(mu), small, small, small)
upN <- c(10*abs(mu), 100*abs(mu), 1-small, 1-small)
fitN <- nlminb(star=parN, objective=llhGARCHSK11N, x = x, lower=lowN,
upper=upN,
               control=list(x.tol = 1e-8,trace=1))

#
------------------------------------------------------------------------------

Thanks in Advance!

On Wed, Feb 16, 2011 at 7:22 AM, Johannes Lips <johannes.lips@googlemail.com
> wrote:

> Hello,
>
> I'm quite new to R but tried to learn as much as possible in the last
> few months.
> My problem is that I would like to estimate the model of Leon et al.
> (2005).
> I have shortly summarised the most important equations in the following
> pdf file:
> http://hannes.fedorapeople.org/leon2005.pdf
>
> My main question is now how could I introduce these two additional terms
> into the Likelihood function of a(n) (existing) GARCH method.
>
> I looked into some GARCH packages but wasn't really sure where to start.
> I know that this is not really an easy task but I would be very grateful
> if you could help me out by giving me some hints on how to solve this
> problem.
>
> Thanks in advance!
>
> Johannes Lips
>
> P.S. I sent this e-mail also to the R-help mailing list but was told I
> should better send it to the finance-sig.
> https://stat.ethz.ch/pipermail/r-help/2011-February/268871.html
>

	[[alternative HTML version deleted]]

