Page 1 of 1

ANST-garch estimation

Posted: Wed Nov 05, 2014 8:52 pm
by huanpipt
Dear Sir/Madam,

Recently, I tried modifying my old anst-garch model into a new version in order to run the forecasting programme, which is a bivariate anst-garch with BEKK specification, and I included two period lagged terms(t-1,t-2) in the mean equation. When maximising the log likelihood function, I got the error message
' ## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Point' .

Can anyone help me with this, please?

Code: Select all

compute n=2
compute gstart = 1,gend = 1678
compute lag = 4, step = 123

linreg LSP gstart gend-step ECTEQ
# constant LF1M

*
* Run preliminary VAR(1) to get estimates of residuals
*

linreg Y gstart+LAG-2 gend-step u1
# constant Y{1} X{1} Y{2} X{2} ecteq{1}
*set u1 = u(1)^2

linreg X gstart+LAG-2 gend-step u2
# constant Y{1} X{1} Y{2} X{2} ecteq{1}
*set u2 = u(2)^2

*


linreg dLSP gstart+LAG-2 gend-step ress
# constant dLSP{1} DLF1M{1} dLSP{2} dLF1M{2} u1 u2 ecteq{1}
compute CS1=%beta(1),$
        TS11S=%beta(2),$
        TS21S=%beta(3),$
        TS11F=%beta(4),$
        TS21F=%beta(5),$
        FS1S=%beta(6),$
        FS1F=%beta(7),$
        ECS=%beta(8)

set rs = ress
set fs = (1-exp(-50*rs{1}))^(-1)

VCV(MATRIX=COVM)
# ress
COMPUTE U11STORE=COVM(1,1)
set HS = (covm(1,1))


linreg dLF1M  gstart+LAG-2 gend-step resf
# constant dLSP{1} dLF1M{1} dLSP{2} dLF1M{2} u1 u2 ecteq{1}
compute CF1=%beta(1),$
        TF11S=%beta(2),$
        TF21S=%beta(3),$
        TF11F=%beta(4),$
        TF21F=%beta(5),$
        FF1S=%beta(6),$
        FF1F=%beta(7),$
        ECF=%beta(8)


set rf = resf
set ff = (1-exp(-50*rf{1}))^(-1)

VCV(MATRIX=COVM)
# resf
COMPUTE U22STORE=COVM(1,1)
set HF = (covm(1,1))

VCV(MATRIX=www)
# ress resf
COMPUTE U21STORE=COVM(1,2)
set HSF = covm(1,2)
COM CORR=%corr(ress,resf)
SET rho = CORR




nonlin(parmset=standmeans) ECS CS1 CS2 CS3 TS11S TS21S TS11F TS21F TS12S TS22S TS12F TS22F TS13S TS23S TS13F TS23F FS1S FS1F FS2S FS2F FS3S FS3F 
nonlin(parmset=standmeanf) ECF CF1 CF2 CF3 TF11S TF21S TF11F TF21F TF12S TF22S TF12F TF22F TF13S TF23S TF13F TF23F FF1S FF1F FF2S FF2F FF3S FF3F
nonlin(parmset=transmean) L
nonlin(parmset=standgarch) A011 A012 A022 A111 A112 A121 A122 A211 A212 A221 A222 B011 B012 B022 B111 B112 B121 B122 B211 B212 B221 B222 D011 D012 D022 D111 D112 D121 D122 D211 D212 D221 D222




*
frml anst = $
    Rs = Y - ECS*ECTEQ{1}-CS1-CS2*fs-CS3*ff $
    -TS11S*Y{1}-TS21S*Y{2}-TS11F*X{1}-TS21F*X{1} $
    -fs*(TS12S*Y{1}-TS22S*Y{2}-TS12F*X{1}-TS22F*X{1})$
    -ff*(TS13S*Y{1}-TS23S*Y{2}-TS13F*X{1}-TS23F*X{1})$
    -FS1S*sqrt(hs)-FS1F*sqrt(hf) $
    -(FS2S*sqrt(hs)-FS2F*sqrt(hf))*fs $
    -(FS3S*sqrt(hs)-FS3F*sqrt(hf))*ff,$
	 Rf = X - ECF*ECTEQ{1}-CF1-CF2*fs-CF3*ff $
    -TF11S*Y{1}-TF21S*Y{2}-TF11F*X{1}-TF21F*X{1} $
    -fs*(TF12S*Y{1}-TF22S*Y{2}-TF12F*X{1}-TF22F*X{1}) $
    -ff*(TF13S*Y{1}-TF23S*Y{2}-TF13F*X{1}-TF23F*X{1}) $
    -FF1S*sqrt(hs)-FF1F*sqrt(hf) $
    -(FF2S*sqrt(hs)-FF2F*sqrt(hf))*fs $
    -(FF3S*sqrt(hs)-FF3F*sqrt(hf))*ff, $
    [sym]Var=||HS(t-1)|HSF(t-1),HF(t-1)||, $
    A0 = ||A011,A012|0.0,A022||,$
    A1 = ||A111,A112|A121,A122||,$
    A2 = ||A211,A212|A221,A222||,$
    B0 = ||B011,A012|0.0,B022||,$
    B1 = ||B111,A112|B121,B122||,$
    B2 = ||B211,A212|B221,B222||,$
    D0 = ||D011,D012|0.0,D022||,$
    D1 = ||D111,D112|D121,D122||,$
    D2 = ||D211,D212|D221,D222||,$
    RRA = ||ress(t-1),resf(t-1)||*A1,$
    RRB = ||ress(t-1),resf(t-1)||*B1,$
    RRD = ||ress(t-1),resf(t-1)||*D1,$
    [sym]G = TR(A0)*A0 + %MQFORM(VAR,A2) +TR(RRA)*RRA+fs*(TR(B0)*B0 + %MQFORM(VAR,B2) +TR(RRB)*RRB)+ff*(TR(D0)*D0 + %MQFORM(VAR,D2) +TR(RRD)*RRD), $
    HS = G(1,1),HF = G(2,2),HSF = G(1,2),$
    rho = HSF/sqrt(HS*HF),$
    fs = 1/(1-exp(-1*L*Rs{1})),ff(t) = 1/(1-exp(-1*L*Rf{1})),$
    ll = %logdensity(||HS,HSF|HSF,HF||,||Rs,Rf||),$
    (ress(t)=Rs(t)),$
    (resf(t)=Rf(t)),$
    ll


comp WWW=%decomp(www)
compute L = 50
comp A011=WWW(1,1),A012=WWW(1,2),A022=WWW(2,2)
comp A111=0.02,A112=0.02,A121=0.02,A122=0.02
comp A211=0.70,A212=0.70,A221=0.70,A222=0.70
comp B011=WWW(1,1),B012=WWW(1,2),B022=WWW(2,2)
comp B111=0.01,B112=0.01,B121=0.01,B122=0.01
comp B211=0.10,B212=0.10,B221=0.10,B222=0.10
comp D011=WWW(1,1),D012=WWW(1,2), D022=WWW(2,2)
comp D111=0.01,D112=0.01,D121=0.01,D122=0.01
comp D211=0.10,D212=0.10,D221=0.10,D222=0.10


maximize(trace,parmset=standmeans+standmeanf+standgarch,pmethod=simplex,piters=10,method=bfgs,iters=10) anst gstart+lag gend-step
maximize(trace,parmset=standmeans+standmeanf+transmean+standgarch,pmethod=bfgs,piters=10,method=bfgs,iters=4000,subiters=200,CVCRIT=0.0000000000000000001) anst gstart+lag gend-step

Re: ANST-garch estimation

Posted: Thu Nov 06, 2014 8:18 am
by TomDoan
With half a program and no data, it's not easy to help. Just from a quick scan, I'm not sure I see why FS and FF are used at the top of the expression but computed at the bottom. The ANST FRML is computed from top to bottom in order, so you have to make sure that you get the subcalculations done in the correct order.

Also your transition functions don't look correct:

fs = 1/(1-exp(-1*L*Rs{1})),ff(t) = 1/(1-exp(-1*L*Rf{1})),

Isn't that supposed to be 1+exp(...), not 1-exp(...)? You should also use the %LOGISTIC function for doing that calculation to avoid overflow problems.

The User's Guide has a description of how to troubleshoot problems like this (page UG-300 in v9 and UG-294 in v8).

Re: ANST-garch estimation

Posted: Mon Nov 10, 2014 9:32 pm
by huanpipt
Dear Tom,

Thank you for the help. I have successfully run the code.

Now, I tried running the code for forecasting, but I got this error message
'## M7. Untrapped Floating Point Error: Overflow or NA
The Error Occurred At Location 6407 of loop/block
Line 165 of loop/block'

I have uploaded both code and data. Could please help me with this?

Best,
Chihyueh

Re: ANST-garch estimation

Posted: Tue Nov 11, 2014 8:43 am
by TomDoan
As I mentioned, the User's Guide has a description of how to troubletshoot this. You shouldn't be trying to do the loop and the forecasting until you actually get the model to fit in the first place. If you just try to evaluate the log likelihood at your guess values, it goes explosively negative, so you have bad guess values. Have you tried fitting this with a fixed BEKK model first?

Re: ANST-garch estimation

Posted: Wed Nov 12, 2014 12:09 pm
by huanpipt
Hi Tom,

I actually did fit the model before doing the loop forecasting, but I did not copy the initial value correctly in the last file.
However, it seems like my model is very sensitive to the setting of initial value and the sample data, since it does not converge from the 2nd point during the loop.
I have tried using estimates of fixed BEKK as initial value, but it does not work so well.
Do you suggest me keep guessing the initial value?

Re: ANST-garch estimation

Posted: Wed Nov 12, 2014 1:35 pm
by TomDoan
You'll never get convergence with a CVCRIT like that:

maximize(parmset=standmeans+standmeanf+transmean+standgarch,pmethod=bfgs,piters=10,method=bfgs,iters=5000,subiters=800,CVCRIT=0.00000000000000000000001) anst gstart+lag gend-step+I-1

The huge limit on the subiterations won't help either. Those are both addressed in Chapter 4 of the User's Guide (the CVCRIT on the first page of the chapter). Rolling sample GARCH models are generally not particularly easy to fit, and a rolling sample two break transition model is likely to be much worse. I would suggest fitting over the full sample, then using those estimates and the corresponding covariance matrix as the guess values for the subsamples. However, you may run into problems if a subsample doesn't really exercise one of the breaks---if that happens the model is unidentified and won't converge.

Re: ANST-garch estimation

Posted: Wed Nov 12, 2014 1:48 pm
by huanpipt
Hi Tom,

Thank you for your advise. I will try and hope it works.

Best,
Chihyueh