[R-SIG-Finance] GARCH estimation
Patrick Burns
patrick at burns-stat.com
Wed Dec 5 18:03:43 CET 2007
You need to do something in the event that ht
becomes non-positive. For example, something
like:
if(ht <= 0) ht <- 1e-10
What number you use will depend on what the
reasonable range of values is for the particular
problem.
Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
ShyhWeir Tzang wrote:
>Dear all:
>
>I have a garch equation different from the traditional one:
>
> y(t)=b1+b2*x(t) + sqrt(h(t))*z(t), where z(t)~N(0,1) h(t)=b3+b4*h(t-1)+b5*(
>z(t-1)-b6*sqrt(h(t-1) )^2
>
>I tried to use optim to estimate the six parameters:
>
>garch <- function(b,x,y){
> b1<-b[1]
> b2<-b[2]
> b3<-b[3]
> b4<-b[4]
> b5<-b[5]
> b6<-b[6]
> N<-length(y)
> lkhd<-0
> ht<-var(y)
> for (i in 1:N){
> zt<-y[i]-b1-b2*x[i]
> ht<-b3+b4*(ht)^2+b5*(zt/sqrt(ht)-b6*sqrt(ht))^2
> lkhd<-lkhd +log(ht)+zt^2/ht
> }
> return(lkhd)
>}
>optim(c(0.01,0.2,0.2,0.2,0.2,0.2),method="BFGS",fn=garch,
> x=data.x,y=data.y)
>
>However, I got the following warnings:
>In log(ht) : create NaNs
>In sqrt(ht) : create NaNs
>........................
>
>Can anyone help me interpreting these warnings? Are there any other better
>way to estimate the parameters? Thank you very much.
>
>ShyhWeir
>
> [[alternative HTML version deleted]]
>
>_______________________________________________
>R-SIG-Finance at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>-- Subscriber-posting only.
>-- If you want to post, subscribe first.
>
>
>
>
More information about the R-SIG-Finance
mailing list