garch model estimation

2 messages Options
Embed this post
Permalink
ShyhWeir Tzang

garch model estimation

Reply Threaded More More options
Print post
Permalink
Dear Sir:

I tried to use the codes provided by Yohan Chalabi and Diethelm Würtz in
their presentation "GARCH Modeling with R/Rmetrics
A Case Study presented at the Meielisalp Workshop on Computational Finance
and Financial Engineering" ( or see
www.*rmetrics*.org/Meielisalp2007/Presentations/Chalabi.pdf<http://www.rmetrics.org/Meielisalp2007/Presentations/Chalabi.pdf>
).
I used the data from the package fPortfolio like the following.
But the results seem not right as the estimated parameters such as alpha and
beta didn't change at all. Can someone or the authors help me out? Another
question is how to compute the standard errors and t values "numerically" by
the R code? Any hint or help is highly appreciated.

Best regards,

ShyhWeir

library("fPortfolio")
SBI.RET<-SWX.RET$SBI

garchInit=function(series) {
    Mean=mean(series); Var=var(series); S=1e-6
    params=c(mu=Mean, omega=0.1*Var, alpha=0.1, beta=0.8)
    lowerBounds=c(mu=-10*abs(Mean), omega=S^2, alpha=S, beta=S)
    upperBounds=c(mu=10*abs(Mean), omega=100*Var, alpha=1-S, beta=1-S)
    cbind(params=params, lowerBounds=lowerBounds, upperBounds=upperBounds)
}

init<-garchInit(SBI.RET)

garchDist=function(z,hh) {dnorm(x=z/hh)/hh}

garchLLH=function(parm, series){
    mu=parm[1]; omega=parm[2]; alpha=parm[3]; beta=parm[4]
    z=(series-mu)
    Mean=mean(z^2)
    #Use Filter Representation;
    e=omega+alpha*c(Mean, z[-length(series)]^2)
    h=filter(e, beta, "r", init=Mean)
    hh=sqrt(abs(h))
    llh=-sum(log(garchDist(z, hh)))
    llh
}

garchllFit=function(series, params, lowerBounds, upperBounds) {
     fit=nlminb(start=params, objective=garchLLH,
               lower=lowerBounds, upper=upperBounds,
                control=list(trace=3), series=series)
     fit
}

garchllFit(SBI.RET, init[,1], init[,2],init[,3])

        [[alternative HTML version deleted]]


_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.
Yohan Chalabi

Re: garch model estimation

Reply Threaded More More options
Print post
Permalink
>>>> "ST" == ShyhWeir Tzang <[hidden email]>
>>>> on Thu, 22 Oct 2009 20:16:48 +0800

   ST> I used the data from the package fPortfolio like the following.
   ST> But the results seem not right as the estimated parameters
   ST> such as alpha and
   ST> beta didn't change at all. Can someone or the authors help me
   ST> out? Another
   ST> question is how to compute the standard errors and t values
   ST> numerically by
   ST> the R code? Any hint or help is highly appreciated.


Hi ShyhWeir,

Your data set is badly scaled for the optimization and you should first
check if there is any GARCH process in it.

try out with the data from package fGarch :

# after your code
library(fGarch)
data(dem2gbp)
x <- dem2gbp[,1]
init<-garchInit(x)
garchllFit(x, init[,1], init[,2],init[,3])

This gives me the same fitted parameters as on the presentation.

You might be interested by the paper of Zivot on "Practical Issues in
the Analysis of GARCH Models" which is available on his website.

HTH,
Yohan

--
PhD candidate
Swiss Federal Institute of Technology
Zurich

www.ethz.ch

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only.
-- If you want to post, subscribe first.