Page 1 of 1

GARCHUVMAX.RPF

Posted: Tue May 03, 2011 2:23 am
by sulong
I am trying to modify the GARCHUVMAX.RPF to fit a GARCH(2,1) without the AR(1) in the mean model.
Did i make a mistake - the output differs form that generated by GARCH(P=2,Q=1) / DLOGDM

Thanks Tom.

Code: Select all

linreg dlogdm
# constant 

frml(lastreg,vector=beta) meanf
nonlin(parmset=meanparms) beta
*
set uu = %seesq
set h  = %seesq
set u  = 0.0
*
nonlin(parmset=garchparms) c a b b2
compute c=%seesq,a=.11,b=.86, b2=0.3
frml varf = c+a*uu{1} + b*h{1} + b2*h{2}
*
frml logl = (u=dlogdm-meanf),(uu(t)=u^2),(h(t)=varf(t)),%logdensity(h,u)
maximize(parmset=meanparms+garchparms) logl 3 *

Re: GARCHUVMAX.RPF

Posted: Tue May 03, 2011 12:29 pm
by TomDoan
As with your other example, there are minor differences in the initialization. GARCH uses 1/T rather than 1/(T-k) in computing the variance for the pre-sample values. GARCH also can estimate starting with entry 2, as it handles the two lags of the variance internally, while MAXIMIZE won't let you use entry 0 for the 2nd lag of H.

Your biggest problem, however, is with the guess values: a=.11,b=.86, b2=0.3. Those are really explosive. If the variance overflows at the guess values, you'll get a truncated data set, as MAXIMIZE will restrict itself to the subset of data where the model can be calculated.

The following will give identical answers for MAXIMIZE and GARCH. This comes at the cost of dropping a data point for the GARCH (it could start at 2).

Code: Select all

OPEN DATA garch.asc
DATA(FORMAT=PRN,NOLABELS,ORG=COLUMNS) 1 1867 BP CD DM JY SF
set dlogdm = 100*log(dm/dm{1})
*
linreg dlogdm 3 *
# constant 

frml(lastreg,vector=beta) meanf
nonlin(parmset=meanparms) beta
*
set uu = %sigmasq
set h = %sigmasq
set u = 0.0
*
nonlin(parmset=garchparms) c a b b2
compute c=%seesq*.1,a=.11,b=.70, b2=.05
frml varf = c+a*uu{1} + b*h{1} + b2*h{2}
*
frml logl = (u=dlogdm-meanf),(uu(t)=u^2),(h(t)=varf(t)),%logdensity(h,u)
maximize(parmset=meanparms+garchparms,trace) logl 3 *
garch(p=2,q=1) 3 * dlogdm
An alternative, which gets the whole range on both, is to shift the data set up an entry with:

DATA(FORMAT=PRN,NOLABELS,ORG=COLUMNS) 2 1868 BP CD DM JY SF

Re: GARCHUVMAX.RPF

Posted: Wed May 04, 2011 7:58 am
by sulong
tom, why do we need to include the following instructions in the code?

set uu = %sigmasq
set h = %sigmasq

Re: GARCHUVMAX.RPF

Posted: Wed May 04, 2011 10:17 am
by TomDoan
sulong wrote:tom, why do we need to include the following instructions in the code?

set uu = %sigmasq
set h = %sigmasq
Those provide the pre-sample values for the lagged variances and lagged squared residuals, and also set up the space needed for filling those in during the actual sample.