Gray's 1996 Regime Switching GARCH
Posted: Mon Oct 03, 2011 8:54 am
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:
*
Thank you very much for your help and time. I greatly appreciate your help.
Sana
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