[R-SIG-Finance] MAR-GARCH

Patrick Burns patrick at burns-stat.com
Sat Oct 27 17:21:19 CEST 2007


DO NOT grow objects as you show:

ht1 <- c()
ht1[1] <- 1
...

Instead create the vector to be the final length and
subscript into it:

ht1 <- numeric(n)
ht1[1] <- 1
...


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")

Nigel.Walker at studentmail.newcastle.edu.au wrote:

>Hi list,
>I am looking at ways to estimate a MAR-GARCH model. What i would like to do is maximise the likelihood function  to obtain the parameters however i am not sure how to do this. I was thinking of using optim but am not sure how to. The problem is i have ht, et, and tau that depend on the parameters i wish to obtain. These ht's, et's and tau's are within the liklihood function. 
>
>The code below is an example of what i need to calculate in order to obtain the likelihood function. The likelihood function is also given. Does anyone know how i would go about maximising the likelihood to obtain the estimates? 
>note that n is the length of the series and the parameters(phis, beta's and gamma's) are first set to initials. 
>Any help would be very welcome
>
>ht1<-c()
>ht1[1]<-1
>ht2<-c()
>ht2[1]<-1
>et1<-c()
>et1[1]<-1
>et1<-c()
>et2[1]<-1
>denominator1<-c()
>denominator1[1]<-1
>denominator2<-c()
>denominator2[1]<-1
>top1<-c()
>top1[1]<-1
>top2<-c()
>top2[1]<-1
>for (L in 2:n){
>ht1[L]=beta10+beta11*(et1[L-1])^2+gamma11*ht1[L-1];
>et1[L]<- rnorm(1,0,sqrt(ht1[L]));
>#yt[L]=phi10+phi11*yt[L-1]+et1[L-1]
>ht2[L]=beta20+beta21*(et2[L-1])^2+gamma21*ht2[L-1];
>et2[L] <- rnorm(1,0,sqrt(ht2[L]))
>#yt[L]=phi20+phi21*yt[L-1]+et2[L-1]
>denominator1[L]<-alpha1*(1/sqrt(ht1[L]))*dnorm(et1[L]/sqrt(ht1[L]))
>denominator2[L]<- alpha2*(1/sqrt(ht2[L]))*dnorm(et2[L]/sqrt(ht2[L]))
>top1[L]<-alpha1*(1/sqrt(ht1[L]))*dnorm(et1[L]/sqrt(ht1[L]))
>top2[L]<-alpha2*(1/sqrt(ht2[L]))*dnorm(et2[L]/sqrt(ht2[L]))
>}
>
># Now to get up tau
>denominator<-denominator1+denominator2
>tau1<-top1/denominator
>tau2<-top2/denominator
>lik.p1<-tau1*log(alpha1)+tau2*log(alpha2)
>lik.p2<- (tau1*log(ht1))/2+(tau2*log(ht2))/2
>lik.p3<- (tau1*et1^2)/(2*ht1)+(tau2*et2^2)/(2*ht2)
>likeli<- lik.p1-lik.p2-lik.p3
>likelihood<- sum(likeli[3:n])
>
>_______________________________________________
>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