[R-SIG-Finance] GARCH estimation
Joshua Reich
josh at gghc.com
Wed Dec 5 18:16:05 CET 2007
Why not use the L-BFGS-B method and supply a lower bound argument?
Josh
-----Original Message-----
From: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Patrick
Burns
Sent: Wednesday, December 05, 2007 12:04 PM
To: ShyhWeir Tzang
Cc: r-sig-finance at stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] GARCH estimation
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.
>
>
>
>
_______________________________________________
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