Page 1 of 1

Conditional variance of SWARCH models

Posted: Thu Jul 05, 2012 6:12 am
by zy761
I'm using the replication file of Hamilton and Susmel(1994): Autoregressive Conditional Heteroskedasticity and Changes in Regime to do the SWARCH model. I was able to obtain the result. This program gives us the residuals and squared residuals. However, I cannot find how to get the conditional variance in the ARCH equation. Can anyone help me how to get the conditional variance? Many thanks in advance!

Re: Conditional variance of SWARCH models

Posted: Thu Jul 05, 2012 11:15 am
by TomDoan
This calculates the one-step-ahead prediction for the variance and graphs it. (It works for either normal or t---the comments on this apply to putting it at the end of the HS_SWARCH_TL32.RPF program.)

Code: Select all

*
* Calculation of one-step-ahead predictions for the variance (bottom
* panel in figure 3). This weights the variance calculations in the
* branches by the predictions of the probabilities of the branches at t
* given t-1.
*
function OneStepVariance time
type real    OneStepVariance
type integer time
*
compute OneStepVariance=0.0
do i=1,nexpand
   compute h=1.0
   do k=1,q
      compute h=h+a(k)*uu(time-k)/gv(%MSLagState(i,k))
   end do k
   compute h=h+d0*%if(u(time-1)<0.0,uu(time-1)/gv(%MSLagState(i,1)),0.0)
   compute OneStepVariance=OneStepVariance+h*gv(%MSLagState(i,0))*pt_t1(time)(i)
end do i
end
*
set sigmahat gstart gend = sqrt(OneStepVariance(t))
set lower = -2.0*sigmahat
set upper = +2.0*sigmahat
*
spgraph(vfields=2,footer="Figure 3 (Top and Bottom Panels)")
graph(hlabel="Return")
# y
graph(hlabel="SWARCH-L(3,2)") 2
# upper
# lower / 1
spgraph(done)

Re: Conditional variance of SWARCH models

Posted: Thu Oct 10, 2013 9:27 pm
by zy761
Dear Tom,

Could you post another example of variance estimation for the Dueker's regime switching GARCH case? I have tried to duplicate and revise your above example to Dueker's code, but it does not seem to work. Appreciate your help a lot! Thanks.

Re: Conditional variance of SWARCH models

Posted: Fri Oct 11, 2013 9:53 am
by TomDoan
That seems to be my program, not yours. It would be better if you showed me what you tried to do that didn't work. It involves taking the GARCHRegimeH function and, rather than returning a VECTOR of regime variances, returning the sum of regime variances weighted by pt_t1(time)(i).

Re: Conditional variance of SWARCH models

Posted: Sat Oct 12, 2013 10:36 pm
by zy761
Dear Tom,

Here is the code I wrote, but actually I am not sure how to deal with GARCHRegimeH(i). I added it at the end of the Dueker's program, and error message turns out that :

## SX15. Trying to Store into Constant or Expression. Called Parameter by Value?
>>>>e GARCHRegimeH(i)=1<<<<

Could you help me with this? Thanks!

Code: Select all

function OneStepVariance time
type real    OneStepVariance
type integer time
*
compute OneStepVariance=0.0
do i=1,nexpand
   compute GARCHRegimeH(i)=1.0+msg(2)*hs(%MSLagState(i,1))(time-1)+$
       msg(1)*uu(time-1)/gv(%MSLagState(i,1))+$
       %if(u(time-1)<0,msg(3)*uu(time-1)/gv(%MSLagState(i,1)),0.0)
   compute OneStepVariance=OneStepVariance+GARCHRegimeH(i)*gv(%MSLagState(i,1))*pt_t1(time)(i)
end do i
end

*
set sigmahat gstart gend = sqrt(OneStepVariance(t))
set lower = -2.0*sigmahat
set upper = +2.0*sigmahat
*
spgraph(vfields=2,footer="Figure 3 (Top and Bottom Panels)")
graph(hlabel="Return")
# y
graph(hlabel="SWARCH-L(3,2)") 2
# upper
# lower / 1
spgraph(done)

Re: Conditional variance of SWARCH models

Posted: Sun Oct 13, 2013 7:51 am
by TomDoan
As in the SWARCH case, you don't need to save each of the variances into a VECTOR when you're just doing the conditional variance. Add LOCAL REAL H, and replace GARCHRegimeH(i) with H.

Re: Conditional variance of SWARCH models

Posted: Mon Oct 14, 2013 12:26 am
by zy761
Thanks Tom! It works.