Gray's 1996 Regime Switching GARCH

Discussion of models with structural breaks or endogenous switching.
sana
Posts: 14
Joined: Sat Jun 21, 2008 3:35 am

Gray's 1996 Regime Switching GARCH

Unread post by sana »

Dear all,
I am working on the Markov switching GARCH model.
I am running the GRAYGARCH alogrithm, but it gives me the following message:
## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points

Please can anyone help me? Here is the used code:

Code: Select all

CALENDAR(M) 2000:01
*allocate 2010 03
all 123
*
open data sentim.xls
data(format=xls,org=columns) / date cac40 
*
*
set fr = 100 * (log(cac40/cac40{1}))
*
display "*********************Hodrick-Prescott_filter***************"
filter(type=hp, tuning=400.0) FR / FF
compute lamda = 400.0
**
DISPLAY "***********************MSGARCH*********************************"
*This makes extensive use of the Markov switching functions and
* procedures from markov.src.
*
source markov.src
compute nstates=2
*
* The P and Q values in Gray's notation are handled in the markov.src
* procedures as an N-1 x N matrix (called P here), with P(i,j) giving the
* probabilities of moving from state j to state i. The Nth row is implicit,
* as it's just the 1-sum of rest of the column.
*
dec rect p(nstates-1,nstates)
*
* PSTAR is a work vector used to keep track of the estimated probablities
* prior to observing the data
*
dec vect pstar(nstates)
*
* These are used to compute smoothed probabilities
*
dec series[vect] pt_t pt_t1 psmooth
gset pt_t     1 2010:03 = %zeros(nstates,1)
gset pt_t1    1 2010:03 = %zeros(nstates,1)
gset psmooth  1 2010:03 = %zeros(nstates,1)
*
*
*******************************************************************************
*
* Table 3 estimates
*
* Single regime GARCH model
*
garch(p=1,q=1,reg,resids=u,hseries=h) / FF
# constant
compute olsvar=%seesq
compute onestate=%beta
*
set usqr  = u**2/h
*
@regcorrs(number=20,report) usqr
*
* Regime-switching GARCH
*
	nonlin a01 a02 a11 a12 b01 b11 b21 b02 b12 b22 p
	compute a01=%beta(1),a11=%beta(2),b01=olsvar,b11=0.0,b21=0.0
	compute a02=%beta(1),a12=%beta(2),b02=%beta(3),b12=%beta(4),b22=%beta(5)
	compute p=||.95,.05||
*
	set uu   = olsvar
	set h    = olsvar
*
* RegimeGARCHF returns the 2 vector of densities in the two states. Again, many
* lines in this are specific to the problem at hand.
*
	function RegimeGARCHF t
	type vector RegimeGARCHF
	type integer t
	local real hh1 hh2 mu1 mu2 mu
	*
	* Compute state dependent variances
	*
	compute hh1=b01+b11*uu(t-1)+b21*h(t-1)
	compute hh2=b02+b12*uu(t-1)+b22*h(t-1)
	*
	* Compute state dependent means
	*
	compute mu1=a01+a11*tn(t-1)
	compute mu2=a02+a12*tn(t-1)
	*
	* Compute the return vector (densities in the two states)
	*
	compute RegimeGARCHF=||%density((ftn(t)-mu1)/sqrt(hh1))/sqrt(hh1),$
                       %density((ftn(t)-mu2)/sqrt(hh2))/sqrt(hh2)||
	*
   *
	* Compute the values of uu (squared residual) and h (variance) to be used for
	* the period following
	*
	compute mu=mu1*pstar(1)+mu2*pstar(2)
	compute uu(t)=(ftn(t)-mu)**2
	compute h(t)=pstar(1)*(mu1**2+hh1)+pstar(2)*(mu2**2+hh2)-mu**2
	end
*
frml logl = f=RegimeGARCHF(t),$
    pt_t1=%mcstate(p,pstar),pt_t=pstar=%msupdate(f,pt_t1,fpt),log(fpt)
*
*
compute a01=.1407,a02=-.0011,a11=-$
.0141,a12=.0006,b01=.0004,b11=.4609,b21=.1977,b02=.0099,b12=.1655,b22=.2685,p=||.9739,1-.9896||
maximize(start=(pstar=%mcergodic(p)),method=bfgs,iters=100,pmethod=simplex,piters=50, trace) logl 2 *
*


Thank you very much for your help and time. I greatly appreciate your help.
Sana
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Gray's 1996 Regime Switching GARCH

Unread post by TomDoan »

You lose one data point because of differencing and another because of the lags required for the GARCH process. So your MAXIMIZE instruction needs to start at 3 or later, not at 2.
sana
Posts: 14
Joined: Sat Jun 21, 2008 3:35 am

Re: Gray's 1996 Regime Switching GARCH

Unread post by sana »

Dear TOM,
Thank you for you prompt response.

But it gives me the same message:
## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points

Please what could be the problem?
I greatly appreciate your help.
Sana
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Gray's 1996 Regime Switching GARCH

Unread post by TomDoan »

You never initialize the pre-sample values of uu and h. In the original Gray GARCH program those are made equal to the OLS variance from a fixed coefficient LS estimation.
sana
Posts: 14
Joined: Sat Jun 21, 2008 3:35 am

Re: Gray's 1996 Regime Switching GARCH

Unread post by sana »

Dear Tom;
Thank you for your help.
I’m still trying to run the GRAYGARCH algorithm without any succes.
Here is the used code:

Single regime GARCH model
*
garch(p=1,q=1,reg,resids=u,hseries=h) / FTN
# constant
*
compute olsvar=%seesq
compute onestate=%beta
*
set usqr = u**2/h
statistics u
*
@regcorrs(number=20,report) usqr
*
*Regime-switching GARCH
*
nonlin a01 a02 a11 a12 b01 b11 b21 b02 b12 b22 p
compute a01=%beta(1),a11=%beta(2),b01=olsvar,b11=0.0,b21=0.0
compute a02=%beta(1),a12=%beta(2),b02=%beta(3),b12=%beta(4),b22=%beta(5)
compute p=||.95,.05||
*
set uu = olsvar
set h = olsvar
*
* RegimeGARCHF returns the 2 vector of densities in the two states. Again, many
* lines in this are specific to the problem at hand.
*
function RegimeGARCHF t
type vector RegimeGARCHF
type integer t
local real hh1 hh2 mu1 mu2 mu
*
* Compute state dependent variances
*
compute hh1=b01+b11*uu(t-1)+b21*h(t-1)
compute hh2=b02+b12*uu(t-1)+b22*h(t-1)
*
* Compute state dependent means
*
compute mu1=a01+a11*ftn(t-1)
compute mu2=a02+a12*ftn(t-1)
*
*
* Compute the return vector (densities in the two states)
*
compute RegimeGARCHF=||%density((ftn(t)-mu1)/sqrt(hh1))/sqrt(hh1),$
%density((ftn(t)-mu2)/sqrt(hh2))/sqrt(hh2)||
*
*
* Compute the values of uu (squared residual) and h (variance) to be used for
* the period following
*
compute mu=mu1*pstar(1)+mu2*pstar(2)
compute uu(t)=(ftn(t)-mu)**2
compute h(t)=pstar(1)*(mu1**2+hh1)+pstar(2)*(mu2**2+hh2)-mu**2
end
*
frml logl = f=RegimeGARCHF(t),$
pt_t1=%mcstate(p,pstar),pt_t=pstar=%msupdate(f,pt_t1,fpt),log(fpt)
*
*
* This combination is able to locate Gray's results - the first MAXIMIZE
* works with the "p" matrix fixed at a fairly high level of persistence,
* and tries to get estimates which separate the two states. The second then
* adds the p matrix to the parmset.
*
nonlin a01 a02 a11 a12 b01 b11 b21 b02 b12 b22=.2685
maximize(start=(pstar=%mcergodic(p)),method=bfgh,iters=500,pmethod=simplex,piters=20) logl 3 *
nonlin a01 a02 a11 a12 b01 b11 b21 b02 b12 b22 p
maximize(start=(pstar=%mcergodic(p)),method=bfgh,iters=200,piters=20) logl 3 *
*




The following message appears ;


MAXIMIZE - Estimation by BFGS
NO CONVERGENCE IN 6 ITERATIONS
LAST CRITERION WAS 0.0000000
SUBITERATIONS LIMIT EXCEEDED. ESTIMATION POSSIBLY HAS STALLED OR MACHINE ROUNDOFF IS MAKING FURTHER PROGRESS DIFFICULT.
TRY HIGHER SUBITERATIONS LIMIT, TIGHTER CVCRIT, DIFFERENT SETTING FOR EXACTLINE OR ALPHA ON NLPAR.
RESTARTING ESTIMATION FROM LAST ESTIMATES OR DIFFERENT INITIAL GUESSES MIGHT ALSO WORK
Monthly Data From 2000:03 To 2010:03
Usable Observations 121
Function Value 135.13871303

Variable Coeff Std Error T-Stat Signif
*******************************************************************************
1. A01 0.000268346 0.001155432 0.23225 0.81634607
2. A02 -0.001397852 0.002557190 -0.54664 0.58462890
3. A11 0.043470630 0.003885935 11.18666 0.00000000
4. A12 1.022065984 0.002305481 443.32009 0.00000000
5. B01 -0.000005272 0.031730944 -1.66134e-04 0.99986744
6. B11 0.004776921 0.675041062 0.00708 0.99435383
7. B21 0.339664598 2.257604427 0.15045 0.88040680
8. B02 0.004328424 0.000456577 9.48017 0.00000000
9. B12 1.173505636 0.006760769 173.57576 0.00000000
10. B22 -0.960569797 0.007024958 -136.73673 0.00000000
11. P(1,1) 0.616715992 0.003441116 179.21977 0.00000000
12. P(1,2) 0.003295439 0.000031004 106.29116 0.00000000



Would you please tell me how to handle the problem??
Thank you.
moderator
Site Admin
Posts: 269
Joined: Thu Oct 19, 2006 4:33 pm

Re: Gray's 1996 Regime Switching GARCH

Unread post by moderator »

We can take a look at the code, but first: have you read and worked through the troubleshooting suggestions in the non-linear estimation section of the User's Guide?

For example, if you have version 8, please see Chapter 4 and, in particular, pages 152-154 of the User's Guide.

Regards,
Tom Maycock
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Gray's 1996 Regime Switching GARCH

Unread post by TomDoan »

sana wrote:The following message appears ;


MAXIMIZE - Estimation by BFGS
NO CONVERGENCE IN 6 ITERATIONS
LAST CRITERION WAS 0.0000000
SUBITERATIONS LIMIT EXCEEDED. ESTIMATION POSSIBLY HAS STALLED OR MACHINE ROUNDOFF IS MAKING FURTHER PROGRESS DIFFICULT.
TRY HIGHER SUBITERATIONS LIMIT, TIGHTER CVCRIT, DIFFERENT SETTING FOR EXACTLINE OR ALPHA ON NLPAR.
RESTARTING ESTIMATION FROM LAST ESTIMATES OR DIFFERENT INITIAL GUESSES MIGHT ALSO WORK
Monthly Data From 2000:03 To 2010:03
Usable Observations 121
Function Value 135.13871303

Variable Coeff Std Error T-Stat Signif
*******************************************************************************
1. A01 0.000268346 0.001155432 0.23225 0.81634607
2. A02 -0.001397852 0.002557190 -0.54664 0.58462890
3. A11 0.043470630 0.003885935 11.18666 0.00000000
4. A12 1.022065984 0.002305481 443.32009 0.00000000
5. B01 -0.000005272 0.031730944 -1.66134e-04 0.99986744
6. B11 0.004776921 0.675041062 0.00708 0.99435383
7. B21 0.339664598 2.257604427 0.15045 0.88040680
8. B02 0.004328424 0.000456577 9.48017 0.00000000
9. B12 1.173505636 0.006760769 173.57576 0.00000000
10. B22 -0.960569797 0.007024958 -136.73673 0.00000000
11. P(1,1) 0.616715992 0.003441116 179.21977 0.00000000
12. P(1,2) 0.003295439 0.000031004 106.29116 0.00000000



Would you please tell me how to handle the problem??
Thank you.
The best solution is to not use Gray's model. It doesn't really work well in the original paper, and I've never seen an example where it did. If you look at the results that you have, neither branch of the switch is a reasonable "GARCH" model. Branch 1 has a negative intercept, branch 2 has wild looking lag coefficients.
sana
Posts: 14
Joined: Sat Jun 21, 2008 3:35 am

Re: Gray's 1996 Regime Switching GARCH

Unread post by sana »

Thank youTom,
I think the best solution is to use the Klaassen, F. (2002) swgarch model. However, I didn't find the rats code.
Any help or suggestions please.
Thanks,
Sana
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Gray's 1996 Regime Switching GARCH

Unread post by TomDoan »

sana wrote:Thank youTom,
I think the best solution is to use the Klaassen, F. (2002) swgarch model. However, I didn't find the rats code.
Any help or suggestions please.
Thanks,
Sana
I don't know about Klassen's model, but we have the code for Dueker's at

http://www.estima.com/forum/viewtopic.php?f=8&t=1190

That's superior to Gray's in several ways - it doesn't collapse the information as quickly, and it doesn't let as much of the model "switch". (The problem with Gray's model in practice is that the branches tend not to form well-behaved ARCH processes).
Post Reply