RATS 10.1
RATS 10.1

Examples /

GARCHMVBOOTSTRAP.RPF

Home Page

← Previous Next →

GARCHMVBOOTSTRAP.RPF is an example of bootstrapping (for out-of-sample simulations) for MV GARCH models. It does both a DVECH model (any "VECH" family model can be done in a similar fashion) and a DCC model; the DCC model, in particular, requires a very different recursion from the VECH family.

 

GARCHBOOT.RPF and EGARCHBOOTSTRAP.RPF are simpler examples of bootstrapping univariate GARCH and EGARCH models. As in those simpler cases, you can't reshuffle the residuals from multivariate GARCH models because they have a complicated (second order) dependence pattern. Instead, you have to (jointly) standardize the residuals at time \(t\) using the GARCH covariance matrix at \(t\), reshuffle the standardized residuals, then use the GARCH model to rebuild a set of residuals with the desired GARCH properties.

Full Program
 

open data g10xrate.xls
data(format=xls,org=columns) 1 6237 usxjpn usxfra usxsui
*
set xjpn = 100.0*log(usxjpn/usxjpn{1})
set xfra = 100.0*log(usxfra/usxfra{1})
set xsui = 100.0*log(usxsui/usxsui{1})
***********************************************************************
*
* Multivariate GARCH model with DVECH. This same basic idea applies to
* any of the models supported by MVGARCHTOVECH. You have to save the
* residuals (most conveniently done using RVECTORS since we need to keep
* the time periods together) and the H matrices.
*
garch(p=1,q=1,pmethod=simplex,piters=10,rvectors=rv,hmatrices=h) / xjpn xfra xsui
compute gstart=%regstart(),gend=%regend()
*
@MVGARCHtoVECH(mv=standard)
*
* Create the series of outer products of the residuals
*
dec series[symm] uu
gset uu gstart gend = %outerxx(rv)
*
* Create the formula for updating the GARCH variance
*
dec frml[symm] hf
frml hf = %vectosymm(%%vech_c+%%vech_b*%vec(h{1})+%%vech_a*%vec(uu{1}),%nvar)
*
* Transform residuals into standardized form
*
dec series[vect] rvstd
gset rvstd gstart gend = %solve(%decomp(h(t)),rv(t))
*
* Bootstrap model for 10 periods out-of-sample. 10000 repetitions
*
compute span=10
compute ndraws=10000
compute bstart=gend+1,bend=gend+span
*
* Extend UU and H out-of-sample. (Values don't really matter at this
* point).
*
gset uu bstart bend = uu{1}
gset h  bstart bend = h{1}
*
dec series[vect] portfolio
gset portfolio bstart bend = %unitv(%nvar,1)
*
set returns 1 ndraws = %na
*
compute [vector] ones=%fill(%nvar,1,1.0)
*
do draw=1,ndraws
   boot entries bstart bend gstart gend
   *
   * Update the variance, post-multiply the shuffled standardized
   * residuals by a square root of the variance, save the outer product
   * and return the re-flated residuals.
   *
   gset rv bstart bend = h=hf,uboot=%decomp(h)*rvstd(entries(t)),uu=%outerxx(uboot),uboot
   *
   * Compute cumulative return on minimum variance portfolio. (This
   * assumes zero mean returns).
   *
   gset portfolio bstart bend = hinv=inv(h),hinv*ones/%qform(hinv,ones)
   sstats bstart bend %dot(portfolio,rv)>>returns(draw)
end do draw
*
* Get quantiles on the performance of the portfolio
*
stats(fractiles) returns 1 ndraws
***********************************************************************
*
* MV GARCH with DCC
*
garch(p=1,q=1,mv=dcc,rvectors=rv,hmatrices=h) / xjpn xfra xsui
compute gstart=%regstart(),gend=%regend()
*
* Transform residuals into standardized form. For a DCC model, there are
* two types of standardizations necessary - one set transforms the
* residuals down to fully uncorrelated with unit variances (RVSTD) and
* one which merely standardizes each variance but leaves correlations
* intact (RVSTDC). Also save the vectors of variances and squared
* residuals.
*
dec series[vect] rvstd rvstdc
dec series[vect] hv uuv
gset rvstd  gstart gend = %solve(%decomp(h(t)),rv(t))
gset rvstdc gstart gend = rv(t)./%xdiag(h(t))
gset hv     gstart gend = %xdiag(h(t))
gset uuv    gstart gend = rv(t).*rv(t)
*
* Set up the individual variance recursions
*
dec vect %%g_c(%nvar) %%g_a(%nvar) %%g_b(%nvar)
ewise %%g_c(i)=%beta(%nregmean+0*%nvar+i)
ewise %%g_a(i)=%beta(%nregmean+1*%nvar+i)
ewise %%g_b(i)=%beta(%nregmean+2*%nvar+i)
*
dec frml[vect] hvf
frml hvf = %%g_c+%%g_b.*hv{1}+%%g_a.*uuv{1}
*
* Pull out the DCC recursion coefficients
*
compute %%dcc_a=%beta(%nreg-1),%%dcc_b=%beta(%nreg)
*
* The "constant" term in the DCC recursion is based upon the
* unconditional correlation matrix of the data.
*
vcv(center)
# xjpn xfra xsui
compute qbar=%cvtocorr(%sigma)
*
* Set up the DCC recursion
*
dec series[symm] q
dec frml[symm] qf
frml qf = (1-%%dcc_a-%%dcc_b)*qbar+%%dcc_b*q{1}+%%dcc_a*%outerxx(rvstdc{1})
*
* The Q sequence can't be backed out of the information available from
* GARCH. This re-generates it.
*
gset q gstart   gstart = qbar
gset q gstart+1 gend   = qf(t)
*
* Bootstrap model for 10 periods out-of-sample. 10000 repetitions
*
compute span=10
compute ndraws=10000
compute bstart=gend+1,bend=gend+span
*
* Extend various objects out-of-sample. (Values don't really matter at
* this point).
*
gset uuv    bstart bend = uuv{1}
gset hv     bstart bend = hv{1}
gset h      bstart bend = h{1}
gset q      bstart bend = q{1}
gset rvstd  bstart bend = rvstd{1}
gset rvstdc bstart bend = rvstdc{1}
*
dec series[vect] portfolio
gset portfolio bstart bend = %unitv(%nvar,1)
*
set returns 1 ndraws = %na
*
compute [vector] ones=%fill(%nvar,1,1.0)
*
do draw=1,ndraws
   boot entries bstart bend gstart gend
   *
   * Do the DCC recursion and the recursion for the univariate variances,
   * convert the pair into the covariance matrix, post-multiply the
   * shuffled standardized residuals by a square root of the variance,
   * save the squares for the next GARCH recusion, save the standardized
   * residuals for the next DCC recursion, and return the re-flated
   * residuals.
   *
   * To do the bootstrap, update Q(t) and HV(t). Convert Q to a
   * correlation matrix and create H(t) from the correlations and the
   * variances in HV. Use that to reflate the shuffled fully
   * standardized residuals.
   *
   gset rv bstart bend = q=qf,hv=hvf,h=%corrtocv(%cvtocorr(q),hv),$
     uboot=%decomp(h)*rvstd(entries(t)),uuv=uboot.*uboot,rvstdc=uboot./hv,uboot
   *
   * Compute cumulative return on minimum variance portfolio. (This
   * assumes zero mean returns).
   *
   gset portfolio bstart bend = hinv=inv(h),hinv*ones/%qform(hinv,ones)
   sstats bstart bend %dot(portfolio,rv)>>returns(draw)
end do draw
*
* Get quantiles on the performance of the portfolio
*
stats(fractiles) returns 1 ndraws

Output

The statistics on the simulated returns depend upon random numbers and so will not be exactly reproducible.

 

MV-GARCH - Estimation by BFGS

Convergence in   180 Iterations. Final criterion was  0.0000031 <=  0.0000100

Usable Observations                      6236

Log Likelihood                    -11835.6454

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Mean(XJPN)                    0.004674636  0.006903238      0.67717  0.49830081

2.  Mean(XFRA)                   -0.003474442  0.006786384     -0.51197  0.60867030

3.  Mean(XSUI)                   -0.002331133  0.008361692     -0.27879  0.78040814

 

4.  C(1,1)                        0.008960589  0.001121259      7.99154  0.00000000

5.  C(2,1)                        0.005646258  0.000730696      7.72723  0.00000000

6.  C(2,2)                        0.011403662  0.001196925      9.52746  0.00000000

7.  C(3,1)                        0.005959232  0.000763548      7.80466  0.00000000

8.  C(3,2)                        0.009833899  0.001076759      9.13287  0.00000000

9.  C(3,3)                        0.012645698  0.001362519      9.28112  0.00000000

10. A(1,1)                        0.105448983  0.007737425     13.62843  0.00000000

11. A(2,1)                        0.093505182  0.005844222     15.99960  0.00000000

12. A(2,2)                        0.127430154  0.006235690     20.43561  0.00000000

13. A(3,1)                        0.088431373  0.005252148     16.83718  0.00000000

14. A(3,2)                        0.112992867  0.005405432     20.90358  0.00000000

15. A(3,3)                        0.110936860  0.005468652     20.28596  0.00000000

16. B(1,1)                        0.884418010  0.007784760    113.60890  0.00000000

17. B(2,1)                        0.891576893  0.006302766    141.45804  0.00000000

18. B(2,2)                        0.861703430  0.006492651    132.71982  0.00000000

19. B(3,1)                        0.898171217  0.005545496    161.96408  0.00000000

20. B(3,2)                        0.875632965  0.005654273    154.86216  0.00000000

21. B(3,3)                        0.878186944  0.005668731    154.91772  0.00000000


 

Statistics on Series RETURNS

Observations                 10000

Sample Mean              -0.057737      Variance                   2.500103

Standard Error            1.581171      SE of Sample Mean          0.015812

t-Statistic (Mean=0)     -3.651522      Signif Level (Mean=0)      0.000262

Skewness                  0.996806      Signif Level (Sk=0)        0.000000

Kurtosis (excess)        13.986229      Signif Level (Ku=0)        0.000000

Jarque-Bera           83162.124491      Signif Level (JB=0)        0.000000

 

Minimum                 -11.783097      Maximum                   23.893259

01-%ile                  -3.879249      99-%ile                    3.895327

05-%ile                  -2.491524      95-%ile                    2.324091

10-%ile                  -1.862923      90-%ile                    1.699969

25-%ile                  -0.962258      75-%ile                    0.824934

Median                   -0.061246


 

MV-DCC GARCH  - Estimation by BFGS

Convergence in    40 Iterations. Final criterion was  0.0000080 <=  0.0000100

Usable Observations                      6236

Log Likelihood                    -11814.4403

 

    Variable                        Coeff      Std Error      T-Stat      Signif

************************************************************************************

1.  Mean(XJPN)                    0.003987923  0.006009027      0.66366  0.50691089

2.  Mean(XFRA)                   -0.003132340  0.006238983     -0.50206  0.61562576

3.  Mean(XSUI)                   -0.003069840  0.007698257     -0.39877  0.69006207

 

4.  C(1)                          0.008499197  0.001141242      7.44732  0.00000000

5.  C(2)                          0.012485965  0.001377298      9.06555  0.00000000

6.  C(3)                          0.016566678  0.001823971      9.08276  0.00000000

7.  A(1)                          0.151663636  0.009063915     16.73268  0.00000000

8.  A(2)                          0.138383290  0.007750557     17.85463  0.00000000

9.  A(3)                          0.123692432  0.007406780     16.69989  0.00000000

10. B(1)                          0.852004681  0.008025825    106.15790  0.00000000

11. B(2)                          0.848526128  0.007936097    106.91982  0.00000000

12. B(3)                          0.858001040  0.007867699    109.05362  0.00000000

13. DCC(A)                        0.053230483  0.003249015     16.38358  0.00000000

14. DCC(A)                        0.939072178  0.003941594    238.24678  0.00000000


 

Covariance\Correlation Matrix

        XJPN        XFRA        XSUI

XJPN 0.398829261     0.55994     0.56526

XFRA 0.230897587 0.426359710     0.82230

XSUI 0.273707444 0.411684556 0.587880308


 

Statistics on Series RETURNS

Observations                 10000

Sample Mean              -0.030108      Variance                   2.415239

Standard Error            1.554104      SE of Sample Mean          0.015541

t-Statistic (Mean=0)     -1.937328      Signif Level (Mean=0)      0.052733

Skewness                  0.393117      Signif Level (Sk=0)        0.000000

Kurtosis (excess)         5.747051      Signif Level (Ku=0)        0.000000

Jarque-Bera           14019.484674      Signif Level (JB=0)        0.000000

 

Minimum                 -10.880054      Maximum                   17.770789

01-%ile                  -3.886063      99-%ile                    3.811708

05-%ile                  -2.478113      95-%ile                    2.392488

10-%ile                  -1.856786      90-%ile                    1.794328

25-%ile                  -0.915057      75-%ile                    0.856821

Median                   -0.042741


 


Copyright © 2024 Thomas A. Doan