Skip to content

aparch model in rugarch package

2 messages · Jaimie Villanueva, Alexios Ghalanos

#
Jaimie,

It's really quite easy to "open up" the source and look at the code if
you want to make these checks...

Because of the non-differentiability of the absolute value function, an
approximation is used as defined on page 85 of the paper by Hentschel
(the rugarch package follows the exact formulation of the author).

There are 2 errors in your code.
1. You do not use the approximation (error very small)
2. Because delta=lambda, the code uses a special switch:
kdelta=delta*indicator+lambda. In any case, replace delta (which is zero
in the code) with lambda:

Here is the correct code snippet to use (using your notation
and some simplifications for easier reading):
#############################################################
for(i in 2:101)
{

  h[i] =
omega+alpha*(h[i-1]^lambda)*(abs(z[i-1]-eta2)-eta1*(z[i-1]-eta2))^lambda+sum(beta*h[i-1]^lambda)
  h[i] = h[i]^(1/lambda)
  epsilon[i] = h[i]*z[i]
  # since its arma(0,0):
  y[i] = mu+epsilon[i]
}
h=h[-1]
epsilon=epsilon[-1]
y=y[-1]


all.equal(as.numeric(h),as.numeric(sigma(sim.ruGarch)))
[1] "Mean relative difference: 2.601269e-06"
# That's the approximation error.

#############################################################
# Use this to get exact match:
for(i in 2:101)
{

  h[i]= omega + alpha * ( h[i-1]^lambda)*( (sqrt(0.001^2 + ( z[i-1] -
eta2)^2)- eta1* (z[i-1] - eta2))^lambda) + sum(beta*h[i-1]^lambda )
  h[i] = h[i]^(1/lambda)
  epsilon[i] = h[i]*z[i]
  y[i] = mu+epsilon[i]
}

h=h[-1]
epsilon=epsilon[-1]
y=y[-1]

all.equal(as.numeric(h),as.numeric(sigma(sim.ruGarch)))
-Alexios
On 25/02/2014 05:13, Jaimie Villanueva wrote: