## Multivariate ANST-GARCH

Discussions of ARCH, GARCH, and related models

### Multivariate ANST-GARCH

Hello, I want to run a bivariate ANST-GARCH-M.

I have some problem in following part,

Code: Select all
`set rs = uu(t)(1,1)set rf = uu(t)(2,2)set fs = (1+%exp(-L*rs{1}))^(-1)set ff = (1+%exp(-L*rf{1}))^(-1)gset F = ||fs,ff||`

There is a error message
"## SX22. Expected Type REAL, Got MATRIX(REAL) Instead
>>>>xp(-L*rs{1}))^(-1)<<<<"

But I don't know how to revise these part.

Following is whole code.

Code: Select all
`compute n=2compute gstart=1,gend=1555*dec series[vect] Ydec frml[vect] Rdec vect[series] U(n)dec series[vect] ECT*** The paths of the covariance matrices and uu' are saved in the* SERIES[SYMM] named H and UU. UX and HX are used for the current values* of the residual vector and H matrices*declare series[symm] G uu** ux is used when extracting a u vector*declare symm Gx(n,n)declare vect ux(n)** These will be the parameters for the mean equations. These are adjusted to add* variance or covariance terms as needed.*dec vect F(n)dec vect EC(n) C1(n) C2(n)dec rect T1(n,n) T2(n,n) F1(n,n) F2(n,n)nonlin(parmset=meanparms) EC C1 C2 T1 T2 F1 F2 L** Mean model = VAR(1) with sqrt(G) "M" term*frml R = Y-EC.*ECT{1}-C1-C2.*F-T1*Y{1}-T2.*F*Y{1}-F1*%sqrt(%xdiag(G))-F2.*F*%sqrt(%xdiag(G))*gset Y = ||dLSP,dLF1M||linreg LSP / ECTEQ# LF1Mgset ECT = ||ECTEQ,ECTEQ||** Run preliminary VAR(4) to get estimates of residuals**linreg dLSP / u(1)# constant dLSP{1} dLF1M{1} ecteq{1}linreg dLF1M / u(2)# constant dLSP{1} dLF1M{1} ecteq{1}*linreg dLSP# constant dLSP{1} DLF1M{1} u(1) u(2) ecteq{1}compute C1(1)=%beta(1),C2(1)=%beta(1),\$        T1(1,1)=%beta(2),T2(1,1)=%beta(2),\$        T1(1,2)=%beta(3),T2(1,2)=%beta(3),\$        F1(1,1)=%beta(4),F2(1,1)=%beta(4),\$        F1(1,2)=%beta(5),F2(1,2)=%beta(5),\$        EC(1)=%beta(6)linreg dLF1M# constant dLSP{1} dLF1M{1} u(1) u(2) ecteq{1}compute C1(2)=%beta(1),C2(2)=%beta(1),\$        T1(2,1)=%beta(2),T2(2,1)=%beta(2),\$        T1(2,2)=%beta(3),T2(2,2)=%beta(3),\$        F1(2,1)=%beta(4),F2(2,1)=%beta(4),\$        F1(2,2)=%beta(5),F2(2,2)=%beta(5),\$        EC(2)=%beta(6)vcv(matrix=WWW)# u** These are used to initialize pre-sample variances.*gset G  * gend = WWWgset uu * gend = WWWset u(1) = 0.0set u(2) = 0.0*declare frml[symm] Gf*frml logl = \$    Gx    = Gf(t) , \$    G(t)  = Gx, \$    ux    = R , \$    uu(t) = %outerxx(ux), \$    %pt(u,t,ux),\$    %logdensity(Gx,ux)*set rs = uu(t)(1,1)set rf = uu(t)(2,2)set fs = (1+%exp(-L*rs{1}))^(-1)set ff = (1+%exp(-L*rf{1}))^(-1)gset F = ||fs,ff||`
huanpipt

Posts: 23
Joined: Sun Mar 27, 2011 7:52 am

### Re: Multivariate ANST-GARCH

Code: Select all
`set rs = uu(t)(1,1)set rf = uu(t)(2,2)set fs = (1+%exp(-L*rs{1}))^(-1)set ff = (1+%exp(-L*rf{1}))^(-1)gset F = ||fs,ff||`

You have two problems with this. First, you want to use just exp, not %exp in the third and fourth instructions. That's what's giving you the syntax error. However, you have a more fundamental problem. FS and FF depend upon L, which is one of your free parameters. A SET instruction will evaluate those only at the current value of L, so FS and FF won't change when L is updated as part of your estimation (and as a result, neither will F, which uses FS and FF). Instead, I think you want the following:

frml fs = (1+exp(-L*rs{1}))^(-1)
frml ff = (1+exp(-L*rf{1}))^(-1)
dec frml[vect] f
frml F = ||fs,ff||[/code]
TomDoan

Posts: 2725
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Multivariate ANST-GARCH

But there is another problem.
I revised the code as following,
Code: Select all
`set rs = uu(t)(1,1)set rf = uu(t)(2,2)frml fs = (1+exp(-L*rs{1}))^(-1)frml ff = (1+exp(-L*rf{1}))^(-1)dec frml[vect] Ffrml F = ||fs,ff||`

A error message comes
"## MAT15. Subscripts Too Large or Non-Positive
Error was evaluating entry 1"
I have found the error part,

Code: Select all
`set rs = uu(t)(1,1)set rf = uu(t)(2,2)`

After I added following code, the problem has not been solved.
Code: Select all
`dec series rsdec series rf`

This is my whole code, and I attach the data in this post.
Code: Select all
`compute n=2compute gstart=1,gend=1555*dec series[vect] Ydec frml[vect] Rdec vect[series] U(n)dec series[vect] ECTdec series rsdec series rf*** The paths of the covariance matrices and uu' are saved in the* SERIES[SYMM] named H and UU. UX and HX are used for the current values* of the residual vector and H matrices*declare series[symm] G uu** ux is used when extracting a u vector*declare symm Gx(n,n)declare vect ux(n)** These will be the parameters for the mean equations. These are adjusted to add* variance or covariance terms as needed.*dec vect EC(n) C1(n) C2(n)dec rect T1(n,n) T2(n,n) F1(n,n) F2(n,n)dec frml[vect] Fnonlin(parmset=meanparms) EC C1 C2 T1 T2 F1 F2 L** Mean model = VAR(1) with sqrt(G) "M" term*frml R = Y-EC.*ECT{1}-C1-C2.*F-T1*Y{1}-T2.*F*Y{1}-F1*%sqrt(%xdiag(G))-F2.*F*%sqrt(%xdiag(G))*gset Y = ||dLSP,dLF1M||set rs = uu(t)(1,1)set rf = uu(t)(2,2)frml fs = (1+exp(-L*rs{1}))^(-1)frml ff = (1+exp(-L*rf{1}))^(-1)frml F = ||fs,ff||linreg LSP / ECTEQ# LF1Mgset ECT = ||ECTEQ,ECTEQ||** Run preliminary VAR(4) to get estimates of residuals**linreg dLSP / u(1)# constant dLSP{1} dLF1M{1} ecteq{1}linreg dLF1M / u(2)# constant dLSP{1} dLF1M{1} ecteq{1}*linreg dLSP# constant dLSP{1} DLF1M{1} u(1) u(2) ecteq{1}compute C1(1)=%beta(1),C2(1)=%beta(1),\$        T1(1,1)=%beta(2),T2(1,1)=%beta(2),\$        T1(1,2)=%beta(3),T2(1,2)=%beta(3),\$        F1(1,1)=%beta(4),F2(1,1)=%beta(4),\$        F1(1,2)=%beta(5),F2(1,2)=%beta(5),\$        EC(1)=%beta(6)linreg dLF1M# constant dLSP{1} dLF1M{1} u(1) u(2) ecteq{1}compute C1(2)=%beta(1),C2(2)=%beta(1),\$        T1(2,1)=%beta(2),T2(2,1)=%beta(2),\$        T1(2,2)=%beta(3),T2(2,2)=%beta(3),\$        F1(2,1)=%beta(4),F2(2,1)=%beta(4),\$        F1(2,2)=%beta(5),F2(2,2)=%beta(5),\$        EC(2)=%beta(6)compute L = 30vcv(matrix=WWW)# u** These are used to initialize pre-sample variances.*gset G  * gend = WWWgset uu * gend = WWWset u(1) = 0.0set u(2) = 0.0*declare frml[symm] Gf*frml logl = \$    Gx    = Gf(t) , \$    G(t)  = Gx, \$    ux    = R , \$    uu(t) = %outerxx(ux), \$    %pt(u,t,ux),\$    %logdensity(Gx,ux)*** This does a simple GARCH(1,1) model for the variance.*dec symm A1(n,n) A2(n,n) A3(n,n) B1(n,n) B2(n,n) B3(n,n)compute A1=WWW,B1=WWW,A2=%const(0.50),B2=%const(0.50),A3=%const(0.05),B3=%const(0.05)nonlin(parmset=garchparms) A1 A2 A3 B1 B2 B3frml Gf = A1+A2.*G{1}+A3.*uu{1}+(B1+B2.*G{1}+B3.*uu{1})*Fmaximize(trace,parmset=meanparms+garchparms,pmethod=bfgs,piters=100,method=bfgs,iters=200) logl gstart+2 gend** This does a BEKK model for the variance*dec rect AA2(n,n) AA3(n,n) BB2(n,n) BB3(n,n)compute AA2=.05*%identity(n),AA3=.50*%identity(n),BB2=.05*%identity(n),BB3=.50*%identity(n)compute A1=%decomp(WWW),B1=%decomp(WWW)nonlin(parmset=garchparms) A1 AA2 AA3 B1 BB2 BB3frml Gf = A1*tr(A1)+AA3*G{1}*tr(AA3)+AA2*uu{1}*tr(AA2)+(B1*tr(B1)+BB3*G{1}*tr(BB3)+BB2*uu{1}*tr(BB2))*Fmaximize(trace,parmset=meanparms+garchparms,pmethod=bfgs,piters=100,method=bfgs,iters=200) logl gstart+2 gend`
Attachments
TD3insample.xls
huanpipt

Posts: 23
Joined: Sun Mar 27, 2011 7:52 am

### Re: Multivariate ANST-GARCH

Do those SET instructions only over the range for which UU would be actually be defined.
TomDoan

Posts: 2725
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Multivariate ANST-GARCH

I've revised the code as below

declare frml rs
declare frml rf
frml rs = uu(t)(1,1)
frml rf = uu(t)(2,2)

There comes other error message.

## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points

I have concernd the sample number is 1555, and beginning point should be gstart+2 due to the ECT term and one-period lagged.
huanpipt

Posts: 23
Joined: Sun Mar 27, 2011 7:52 am

### Re: Multivariate ANST-GARCH

Dear Tom,

set rs gstart+2 gend = uu(t)(1,1)
set rf gstart+2 gend = uu(t)(2,2)

frml fs = 1/(1+exp(-L*rs{1}))
frml ff = 1/(1+exp(-L*rf{1}))
frml F = ||fs,ff||

, but it doesn't work with the same error message.

and I try to run the following code,

set rs = u(1)
set rf = u(2)

frml fs = 1/(1+exp(-L*rs{1}))
frml ff = 1/(1+exp(-L*rf{1}))
frml F = ||fs,ff||
, it work, but the usable sample is not as I expected.

The much sample is skipped, and every time I run the same code with different usable data which is shown from the result table.

I want to know if the code is wrong to deal with the multivariate smooth transformation function, and how to correct it right.

Hoping hear from your, I am.
huanpipt

Posts: 23
Joined: Sun Mar 27, 2011 7:52 am

### Re: Multivariate ANST-GARCH

Aren't your dimensions wrong on F? It should be a 2 x 2 matrix, not a 2 vector.
TomDoan

Posts: 2725
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Multivariate ANST-GARCH

It really help me a lot.
I forget the F in the mean equation should not be the same as in the variance equation.

I have create a new 2*2 matrix, V, for the variance equation.
It work with correct sample, only the result is not perfect perhaps due to the wrong initial setting.
Following is my added code, would you mind to see if there is still problem.
And I appreciate your helping very much.
Code: Select all
`dec frml[vect] Fdec frml[symm] Vfrml rs = uu(t)(1,1)**(1/2)frml rf = uu(t)(2,2)**(1/2)frml rsf = uu(t)(1,2)**(1/2)frml fs = 1/(1+exp(-L*rs{1}))frml ff = 1/(1+exp(-L*rf{1}))frml fsf = 1/(1+exp(-L*rsf{1}))frml F = ||fs,ff||frml V = ||fs|fsf,ff||`
huanpipt

Posts: 23
Joined: Sun Mar 27, 2011 7:52 am

### Re: Multivariate ANST-GARCH

At this point, it would probably make the most sense for you to e-mail the set of equations that you're trying to estimate to us at support@estima.com.
TomDoan

Posts: 2725
Joined: Wed Nov 01, 2006 5:36 pm