Regime switching GARCH
-
JohnV
Regime switching GARCH
Hi,
I am trying to estimate a regime switching GARCH model identical to Gray (1996). The parameter values blow up and the algorithm breaks down.
I think in writing the program I some how donnot have the recursion written correctly. Can some body please take a look.The program is below.
com p22 = 0.8
com p11 = 0.95
com mean1 = 0.0024
com mean2 = -0.02
com alpha1=0.0002
com alpha2=0.0002
com beta=0.9
com theta=0.069
set sigma1 = 0.000433
set sigma2 = 0.000433
set err = 0.00025
set prob = 0.91
set prob1 = 0.5
nonlin(paramset=pr) p22 p11
nonlin(paramset=constraint) p22<=1.0 p22>=0.0001 p11<=1.0 p11>=0.0001 alpha1>=0.0001 alpha2>=0.0001 beta>=0.0001 theta>=0.0001
nonlin(paramset=m) mean1 mean2
nonlin(paramset=s) alpha1 alpha2 beta theta
frml Likely1 = prob{1}*%density((ret{1}-mean1)/sqrt(sigma1{1}))/sqrt(sigma1{1}) + (1-prob{1})*%density((ret{1}-mean2)/sqrt(sigma2{1}))/sqrt(sigma2{1})
frml P = (1-p22)*(1-prob{1})*%density((ret{1}-mean2)/sqrt(sigma2{1}))/sqrt(sigma2{1})/Likely1(t)
+ p11*prob{1}*%density((ret{1}-mean1)/sqrt(sigma1{1}))/sqrt(sigma1{1})/Likely1(t)
frml error = ret -(P(t)*mean1 + (1-P(t))*mean2)
frml var1 = alpha1 + beta*sigma1{1} + theta*err{1}^2
frml var2 = alpha2 + beta*sigma2{1} + theta*err{1}^2
frml Likely =P(t)*%density((ret-mean1)/sqrt(sigma1))/sqrt(sigma1) + (1-P(t))*%density((ret-mean2)/sqrt(sigma2))/sqrt(sigma2)
frml Logly = (err=error(t)),(sigma1=var1(t)),(sigma2=var2(t)),(prob=P(t)), log(Likely(t))
maximize(parset=pr+m+s+constraint,method=bhhh,iter=100,cvcrit=0.00001) logly 10 3196
I am trying to estimate a regime switching GARCH model identical to Gray (1996). The parameter values blow up and the algorithm breaks down.
I think in writing the program I some how donnot have the recursion written correctly. Can some body please take a look.The program is below.
com p22 = 0.8
com p11 = 0.95
com mean1 = 0.0024
com mean2 = -0.02
com alpha1=0.0002
com alpha2=0.0002
com beta=0.9
com theta=0.069
set sigma1 = 0.000433
set sigma2 = 0.000433
set err = 0.00025
set prob = 0.91
set prob1 = 0.5
nonlin(paramset=pr) p22 p11
nonlin(paramset=constraint) p22<=1.0 p22>=0.0001 p11<=1.0 p11>=0.0001 alpha1>=0.0001 alpha2>=0.0001 beta>=0.0001 theta>=0.0001
nonlin(paramset=m) mean1 mean2
nonlin(paramset=s) alpha1 alpha2 beta theta
frml Likely1 = prob{1}*%density((ret{1}-mean1)/sqrt(sigma1{1}))/sqrt(sigma1{1}) + (1-prob{1})*%density((ret{1}-mean2)/sqrt(sigma2{1}))/sqrt(sigma2{1})
frml P = (1-p22)*(1-prob{1})*%density((ret{1}-mean2)/sqrt(sigma2{1}))/sqrt(sigma2{1})/Likely1(t)
+ p11*prob{1}*%density((ret{1}-mean1)/sqrt(sigma1{1}))/sqrt(sigma1{1})/Likely1(t)
frml error = ret -(P(t)*mean1 + (1-P(t))*mean2)
frml var1 = alpha1 + beta*sigma1{1} + theta*err{1}^2
frml var2 = alpha2 + beta*sigma2{1} + theta*err{1}^2
frml Likely =P(t)*%density((ret-mean1)/sqrt(sigma1))/sqrt(sigma1) + (1-P(t))*%density((ret-mean2)/sqrt(sigma2))/sqrt(sigma2)
frml Logly = (err=error(t)),(sigma1=var1(t)),(sigma2=var2(t)),(prob=P(t)), log(Likely(t))
maximize(parset=pr+m+s+constraint,method=bhhh,iter=100,cvcrit=0.00001) logly 10 3196
Re: Regime switching GARCH
I would recommend Dueker's method instead. I don't think Gray's filtering procedure is accurate enough.
-
JohnV
Re: Regime switching GARCH
Thanks Tom. I am going to read Dueker this weekend. I would still like to know where my programming is off. I am trying to advance my RATS programming abilities.
Re: Regime switching GARCH
1. I'm not sure what variation on Gray(1996) that you are doing, but we do have a replication program for what he did so you don't have to rewrite everything. I would suggest that you use the existing MS support procedures.
2. It's somewhat hard to follow what you did because you keep re-doing the same calculations rather than computing once and saving. As much as possible, do calculations when the time period is current---compute the filtered probabilities through T as part of the calculation of log likelihood at T so they are ready to go when you need to compute T+1. Your P frml is using likelihood information dated T-1 to get predictions for T.
2. It's somewhat hard to follow what you did because you keep re-doing the same calculations rather than computing once and saving. As much as possible, do calculations when the time period is current---compute the filtered probabilities through T as part of the calculation of log likelihood at T so they are ready to go when you need to compute T+1. Your P frml is using likelihood information dated T-1 to get predictions for T.