Extracting the residual series from MGARCH-M model

Discussions of ARCH, GARCH, and related models
msrahman
Posts: 53
Joined: Wed Oct 31, 2012 2:32 pm

Extracting the residual series from MGARCH-M model

Unread post by msrahman »

Hello,
I am using following Multivariate GARCH instruction to estimate a GARCH model. I want to extract the estimated residual series stored in rv. Could you please guide me about how to do this?

Thanks.

----------------------------------
garch(model=garchm,mv=bekk,presample=cv0,$
rvectors=rv,hmatrices=h,$
uadjust=%pt(eps,t,rv(t)),hadjust=%pt(sqrth,t,%sqrt(%xdiag(h(t)))),$
pmethod=simplex,piters=20,init=%beta)
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Extracting the residual series from MGARCH-M model

Unread post by TomDoan »

See page UG-302 in the Version 8 User's Guide. Those are doing standardized residuals, but you can do the same thing without the standardization.
econo
Posts: 32
Joined: Fri Sep 05, 2014 9:16 am

Re: Extracting the residual series from MGARCH-M model

Unread post by econo »

I am trying to extract Standardized residuals (RATS 8.0):

Code: Select all

system(model=var1)
variables O C
lags 1
end(system)

compute cv0=%sigma

garch(p=1,q=1,model=var1,mv=CC,variance=varma,pmethod=simplex,piters=5,hmatrices=Varmah, MVHSERIES=VarmaHmatrix, rvectors=Varmarv,presample=cv0,uadjust=%pt(eps,t,Varmarv(t)),hadjust=%pt(sqrth,t,%sqrt(%xdiag(Varmah(t)))),$
  pmethod=simplex,piters=20 ) gstart gend O C

but face this error:

## OP3. This Instruction Does Not Have An Option UAD
>>>>sample=cv0,uadjust=<<<<
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Extracting the residual series from MGARCH-M model

Unread post by TomDoan »

UADJUST and HADJUST were added with RATS 8.1. There were many additional changes to GARCH with 9.0. I would suggest that you update to v9.
econo
Posts: 32
Joined: Fri Sep 05, 2014 9:16 am

Re: Extracting the residual series from MGARCH-M model

Unread post by econo »

the only way is updating?

how can I get the residuals?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Extracting the residual series from MGARCH-M model

Unread post by TomDoan »

In effect, yes. You can't estimate the model without the new options---they were added precisely to make a model like this (a VARMA-GARCH-M) tractable. And if you can't estimate the model, you can't get the residuals.
econo
Posts: 32
Joined: Fri Sep 05, 2014 9:16 am

Re: Extracting the residual series from MGARCH-M model

Unread post by econo »

I mean, with this code I can estimate the model

Code: Select all

garch(p=1,q=1,model=var1,mv=CC,variance=varma,pmethod=simplex,piters=5,hmatrices=Varmah, MVHSERIES=VarmaHmatrix, rvectors=Varmarv)
Now I have the hmatrices, I can get the sqrt of it.**
if I can get the residuals of this GARCH function, then I have the standardized residuals!




**
{ I dont know how to find SQRT in RATS but code in R is as follow
a.eig <- eigen(a)
a.sqrt <- a.eig$vectors %*% diag(sqrt(a.eig$values)) %*% solve(a.eig$vectors)
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Extracting the residual series from MGARCH-M model

Unread post by TomDoan »

The GARCHMV.RPF example with your version 8 has code for computing multivariate standardized residuals. (Note that there are an infinite number of ways of standardizing a multivariate set of series with each generating a somewhat different set of diagnostics). With version 9, there's a STDRESIDS option which computes it directly. Note that VARIANCES=VARMA has nothing to do with the "VARMA" (mean model) used in the original example in this thread.
econo
Posts: 32
Joined: Fri Sep 05, 2014 9:16 am

Re: Extracting the residual series from MGARCH-M model

Unread post by econo »

Code: Select all


garch(p=1,q=1,model=var1,mv=CC,variance=varma,pmethod=simplex,piters=5,hmatrices=Varmah, MVHSERIES=VarmaHmatrix, rvectors=Varmarv ) gstart gend O c


open copy 2.xls
copy(data,format=xls,org=columns)  /Varmarv

## SX22. Expected Type SERIES[REAL], Got SERIES[VECTOR[REAL]] Instead
>>>>columns) /Varmarv<<<<

How can I save the residuals?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Extracting the residual series from MGARCH-M model

Unread post by TomDoan »

Even if that would work (it won't because RVECTORS produces a SERIES[VECTOR] which COPY doesn't handle), of what use would the non-standardized residuals from a GARCH model be? Those won't be all that different from the residuals from estimating the VAR without the GARCH errors. Compute the standardized residuals using the method shown in your GARCHMV.RPF program and you can apply COPY to them.
econo
Posts: 32
Joined: Fri Sep 05, 2014 9:16 am

Re: Extracting the residual series from MGARCH-M model

Unread post by econo »

Do you mean this code?

Code: Select all

* Estimates for a BEKK with t errors, saving the residuals and the
* variances (in the VECT[SERIES] and SYMM[SERIES] forms), and using them
* to compute the empirical probability of a residual (for Japan) being
* in the left .05 tail.
*
garch(p=1,q=1,mv=bekk,pmethod=simplex,piters=10,distrib=t,$
   rseries=rs,mvhseries=hhs) / xjpn xfra xsui
*
compute fixt=(%shape-2)/%shape
set trigger = %tcdf(rs(1)/sqrt(hhs(1,1)*fixt),%shape)<.05
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Extracting the residual series from MGARCH-M model

Unread post by TomDoan »

No. You don't have version 9 (and that's a completely different calculation anyway). There's a GARCHMV.RPF in your examples folder which works with version 8. GARCHMV.RPF is also described in your User's Guide (Example 9.2) as is the process for obtaining standardized residuals (section 9.8.2). In the code below, the ZU are the multivariate standardized residuals. (Z1, Z2 and Z3 are univariate standardized residuals, which aren't as useful diagnostically).

Code: Select all

garch(p=1,q=1,pmethod=simplex,piters=10,$
   hmatrices=hh,rvectors=rd)  / xjpn xfra xsui
set z1 = rd(t)(1)/sqrt(hh(t)(1,1))
set z2 = rd(t)(2)/sqrt(hh(t)(2,2))
set z3 = rd(t)(3)/sqrt(hh(t)(3,3))
@bdindtests(number=40) z1
@bdindtests(number=40) z2
@bdindtests(number=40) z3
*
* Multivariate Q statistic. This requires transforming the residuals to
* eliminate the time-varying correlations.
*
dec vect[series] zu(%nvar)
do time=%regstart(),%regend()
   compute %pt(zu,time,%solve(%decomp(hh(time)),rd(time)))
end do time
econo
Posts: 32
Joined: Fri Sep 05, 2014 9:16 am

Re: Extracting the residual series from MGARCH-M model

Unread post by econo »

Now it gives me this error:

## MAT15. Subscripts Too Large or Non-Positive
Error was evaluating entry 2355
econo
Posts: 32
Joined: Fri Sep 05, 2014 9:16 am

Re: Extracting the residual series from MGARCH-M model

Unread post by econo »

TomDoan wrote:it won't because RVECTORS produces a SERIES[VECTOR] which COPY doesn't handle[/i].

to export errors vector, I used this code
EWISE rd(t) = X(t)

## SX11. Identifier X is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>EWISE rd(t) = X(<<<<

still doesn't work :(
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Extracting the residual series from MGARCH-M model

Unread post by TomDoan »

I assume this is with your program adapted to your data set. You would have to attach the whole program for us to tell. Which instruction/loop is causing the problem? (Do Show Last Error on the Edit menu).
Post Reply