Page 1 of 4

Rolling-VAR-MGARCH-M

Posted: Sat Sep 01, 2018 10:40 am
by hasanov
The objectives of the code in the attached .RPF file are as follows:

- to estimate VARMA-MGARCH-in-mean model through the rolling windows where the fixed window size is 1250 and increment is 5.
- to generate 5-step ahead volatility forecasts in each window and save these series in hhat11 and hhat22 objects.
- this code also saves some of estimated coefficients from each regression in coef1, coef2, and coef3 objects.

I would be appreciated if anyone could check the code whether everything is OK. I suspect the mean model (i.e., VARMA) and var-cov model (i.e., MGARCH-M) use different sample periods.

Attached is the code file.

Many thanks

Code: Select all


*
set rvar1 = 100.0*(log(var1)-log(var1{1}))
set rvar2 = 100.0*(log(var2)-log(var2{1}))
set rvar3 = 100.0*(log(var3)-log(var3{1}))
*
source mvgarchfore.src
*
compute d=1250
*
dec series hhat11
dec series hhat22
dec series hhat33
*
dec series hhat12
dec series hhat13
dec series hhat23
*
clear hhat11
clear hhat22
clear hhat33
*
clear hhat12
clear hhat13
clear hhat23
*
clear coef1 coef2 coef3 coef4 coef5
clear tstat1 tstat2 tstat3 tstat4 tstat5
clear conv iter
*
dec vect[series] sqrth(3)
dec vect[series] eps(3)
dec symm[series] hhs(3,3)
clear(zeros) hhs
*
do regend = 2013:01:09, 2019:05:31, 5
*
equation oil_eq rvar1
# constant sqrth(1) sqrth(2) sqrth(3) rvar1{1} rvar2{1} rvar3{1}
equation rvar2_eq rvar2
# constant sqrth(1) sqrth(2) sqrth(3) rvar1{1} rvar2{1} rvar3{1}
equation rvar3_eq rvar3
# constant sqrth(1) sqrth(2) sqrth(3) rvar1{1} rvar2{1} rvar3{1}
*
group varmah oil_eq rvar2_eq rvar3_eq
*
clear(zeros) sqrth eps
*
do iters=1,3
   estimate(model=varmah,resids=resids)
   set eps(1) %regstart() * = resids(1)
   set eps(2) %regstart() * = resids(2)
   set eps(3) %regstart() * = resids(3)
end do iters
*
compute cv0=%sigma
*
garch(model=varmah, mv=bekk, robust, distrib=norm, rvectors=rv, hmatrices=hh, mvhseries=hhs, pmethod=simplex, piters=15, cvcrit=0.0001, iters=1000, presample=cv0,$
    uadjust=%pt(eps,t,rv(t)),hadjust=%(sqrth(1)=sqrt(hhs(1,1)), sqrth(2)=sqrt(hhs(2,2)), sqrth(3)=sqrt(hhs(3,3)))) regend-d+1 regend rvar1 rvar2 rvar3
*
@MVGarchFore(MV=BEKK, steps=5) hh rv
*
do i=1,5
compute hhat11(regend+i) = hh(regend+i)(1,1)
compute hhat22(regend+i) = hh(regend+i)(2,2)
compute hhat33(regend+i) = hh(regend+i)(3,3)
end do i
*
compute coef1(regend) = %beta(9)
compute coef2(regend) = %beta(10)
compute coef3(regend) = %beta(11)
compute coef4(regend) = %beta(38)
compute coef5(regend) = %beta(44)
*
compute tstat1(regend) = %tstats(9)
compute tstat2(regend) = %tstats(10)
compute tstat3(regend) = %tstats(11)
compute tstat4(regend) = %tstats(38)
compute tstat5(regend) = %tstats(44)
*
compute conv(regend) = %converged
compute iter(regend) = %ITERS
*
end do regend
*
*
print / coef1 tstat1 coef2 tstat2 coef3 tstat3
*
print / coef4 tstat4 coef5 tstat5
*
print / hhat11 hhat22 hhat33
*
print / conv iter



Re: Rolling-VAR-MGARCH-M

Posted: Mon Sep 03, 2018 8:04 am
by TomDoan
That would be fine except that you're doing an asymmetric BEKK and there is no closed form forecasting procedure for an asymmetric BEKK.

Re: Rolling-VAR-MGARCH-M

Posted: Mon Sep 03, 2018 8:24 am
by hasanov
Thanks Tom!

How about the forecasts generated by procedure (i.e., @MVGarchFore(MV=BEKK, steps=5) hh rv) in the code? Does this procedure ignore the asymmetric component and produce forecasts?

Regards

Re: Rolling-VAR-MGARCH-M

Posted: Mon Sep 03, 2018 8:37 am
by TomDoan
Correct. Because it does the closed-form calculation, it ignores the asymmetry, but your estimates include it, so the forecasts won't be correct.

Note, by the way, that your model has a lot of quite insignificant coefficients, particularly in the mean model. Pick the mean model that's appropriate for your data, not someone else's.

Re: Rolling-VAR-MGARCH-M

Posted: Mon Sep 03, 2018 8:57 am
by hasanov
Many thanks for your prompt reply. Actually, the data is used for preliminary coding purposes. We plan to use the code for different set of data.

Kind Regards,

Re: Rolling-VAR-MGARCH-M

Posted: Mon Sep 10, 2018 8:49 am
by hasanov
Hi Tom,

It is clear that

%BETA - vector for the coefficients
%TSTATS - t-stats for the coefficients
%STDERRS - vector of coefficient standard errors

How about the p-values? Is there any specific vector for p-values?

Thanks

Re: Rolling-VAR-MGARCH-M

Posted: Mon Sep 10, 2018 9:02 am
by TomDoan
No. But you can get those from the t-stats fairly easily. Note, BTW, that "rolling sample" GARCH models are really not a good idea. Fixing the start, and moving the end to do simulated out-of-sample forecasts has some value. Moving the start along with the end isn't well-motivated.

Re: Rolling-VAR-MGARCH-M

Posted: Tue Dec 11, 2018 12:14 am
by hasanov
Hi Tom,

In the procedure below:

@MVGarchFore(MV=BEKK, steps=1) hh rv

Does rv contain fitted values of returns or errors?

How elements of rv vector can be extracted? What commands can be used?

Many Thanks

Re: Rolling-VAR-MGARCH-M

Posted: Tue Dec 11, 2018 9:28 am
by TomDoan
No. RV is input to the procedure---it should be what's produced by the RVECTORS option on GARCH. (Lagged residuals are needed to compute the out-of-sample forecasts).

Re: Rolling-VAR-MGARCH-M

Posted: Sun Dec 16, 2018 3:27 am
by wert12
Dear hasanov, i would be most grateful if you could send me the data file.txt?

Re: Rolling-VAR-MGARCH-M

Posted: Thu Apr 25, 2019 8:00 pm
by hasanov
Hi Tom,

I need to gather the convergence info for each rolling sample estimation and want to store it in a separate vector.

For example, coefficients are stored in %beta? Is there any object in RATS to store the convergence info?

I just need Yes" or "No" info for the numerical convergence for each rolling sample estimation.

Many thanks

Re: Rolling-VAR-MGARCH-M

Posted: Thu Apr 25, 2019 10:51 pm
by TomDoan

Re: Rolling-VAR-MGARCH-M

Posted: Sun Apr 28, 2019 11:49 pm
by hasanov
Hi Tom,

Once the rolling estimation has been done, I used "print / " option to get the results gathered in "ceof" and "hhat11". But it only shows the part of the results, not all of the results. How can I set to print all the results?

Many thanks

Re: Rolling-VAR-MGARCH-M

Posted: Mon Apr 29, 2019 8:25 am
by TomDoan
You have an active SMPL (which, so far as I can tell you never actually use):

smpl regend-d+1 regend roilf
smpl regend-d+1 regend rheatoilf

but that will affect a PRINT / ... instruction. So far as I can tell, you don't need those at all. (Note also that those third parameters on the SMPL's aren't part of the command and are ignored---I'm not sure what you intend those to mean).

Re: Rolling-VAR-MGARCH-M

Posted: Wed May 15, 2019 10:32 am
by hasanov
Hi Tom,

How can I obtain univariate or multivariate auto correlation test statistic for each window and store them in a separate object? Is it possible in RATS? Your advice is highly appreciated.

Thank you