Little Disclaimer

I originally posted this on Stack Overflow, but I'm not sure which is the correct place, because this question demands a knowledge of Econometrics. So, I'll replicate here and if I'm doing something wrong, please let me know :)


I have a csv file of 5 instruments that I want to estimate the Covariance Matrix using rmgarch

The range of the csv file is from 2018-01-02 to 2019-12-11 (482 variables)

When I run the following code:

# Testing Multivariate Garch

# Series
returns <- read.csv('ret.csv')
rownames(returns) <- returns$X
returns$X <- NULL

ret_1 <- head(returns, -1)

# Specs
spec1 = ugarchspec(distribution = "std")
mspec = multispec(rep(c(spec1), times=ncol(returns)))
fitspec = dccspec(mspec, VAR=TRUE, lag=1, dccOrder=c(1,1),model="DCC", distribution="mvt")

# Fitting Model
garchdccfit = dccfit(fitspec, returns, fit.control=list(scale=TRUE)) 

# 1-Step ahead forecast object
forecast <- dccforecast(garchdccfit, n.ahead=1)

# 1-Step ahead covariance matrix
forecast_cov <- rcov(forecast)

# Rolling Forecast - For backtest purpose
roll_forecast <- dccroll(fitspec, returns, n.ahead=1, forecast.length = 1, 
                         refit.every = 1, refit.window = "recursive", 
                         save.fit = TRUE, save.wdir = "W:/Personal Folders/Thales Marques/GarchPython")

# Reading first RDS file
first_fit <- readRDS("dccroll_1.rds", refhook = NULL)

Forecast with Rolling

I understand that roll_forecast variable will behave like:

  • Use the dcc-garch specifications in the variable fitspec
  • Use the returns data (482 obs. of 5 variables)
  • Since forecast.length = 1, it will forecast one step ahead of my sample
  • Save the fit model ouput as a rds file in save.wdir

The output that I get running rcov(roll_forecast) is:

, , 2019-12-11

                PRE_2A        PRE_5A      IBOV_1st       BRL_1st       SPX_1st
PRE_2A    2.234106e-06  4.244793e-06  7.540792e-06 -5.853135e-06  1.864744e-06
PRE_5A    4.244793e-06  1.092654e-05  1.824539e-05 -1.535431e-05  4.155332e-06
IBOV_1st  7.540792e-06  1.824539e-05  1.075482e-04 -3.854478e-05  2.692275e-05
BRL_1st  -5.853135e-06 -1.535431e-05 -3.854478e-05  5.422331e-05 -1.032894e-05
SPX_1st   1.864744e-06  4.155332e-06  2.692275e-05 -1.032894e-05  4.212289e-05

The fit model (stored as dccroll_1.rds) is:

*          DCC GARCH Fit          *

Distribution         :  mvt
Model                :  DCC(1,1)
No. Parameters       :  63
[VAR GARCH DCC UncQ] : [30+20+3+10]
No. Series           :  5
No. Obs.             :  481
Log-Likelihood       :  9616.71
Av.Log-Likelihood    :  19.99 

Optimal Parameters
                   Estimate  Std. Error  t value Pr(>|t|)
[PRE_2A].omega     0.000000          NA       NA       NA
[PRE_2A].alpha1    0.165964          NA       NA       NA
[PRE_2A].beta1     0.757918          NA       NA       NA
[PRE_2A].shape     5.292370          NA       NA       NA
[PRE_5A].omega     0.000001          NA       NA       NA
[PRE_5A].alpha1    0.140100          NA       NA       NA
[PRE_5A].beta1     0.827182          NA       NA       NA
[PRE_5A].shape     8.027201          NA       NA       NA
[IBOV_1st].omega   0.000010          NA       NA       NA
[IBOV_1st].alpha1  0.059325          NA       NA       NA
[IBOV_1st].beta1   0.881198          NA       NA       NA
[IBOV_1st].shape  10.244986          NA       NA       NA
[BRL_1st].omega    0.000001          NA       NA       NA
[BRL_1st].alpha1   0.026141          NA       NA       NA
[BRL_1st].beta1    0.954693          NA       NA       NA
[BRL_1st].shape    9.616442          NA       NA       NA
[SPX_1st].omega    0.000004          NA       NA       NA
[SPX_1st].alpha1   0.196621          NA       NA       NA
[SPX_1st].beta1    0.780560          NA       NA       NA
[SPX_1st].shape    4.486858          NA       NA       NA
[Joint]dcca1       0.009943          NA       NA       NA
[Joint]dccb1       0.969974          NA       NA       NA
[Joint]mshape      7.524895          NA       NA       NA

Information Criteria

Akaike       -39.724
Bayes        -39.177
Shibata      -39.754
Hannan-Quinn -39.509

Elapsed time : 0.2523229 

1) This means that the dccroll looked only for the 1:481 observations, estimated the Covariance Matrix and forecast it for the 482nd observation ('2019-12-11')? Why this doesn't rolled one step out-of-sample like forecast_cov?

Forecast Cov - Without Rolling Method

The forecast_cov (which it's not rolling, just forecast one step ahead, returns the following output:

, , T+1

                PRE_2A        PRE_5A      IBOV_1st       BRL_1st       SPX_1st
PRE_2A    1.955756e-06  3.830893e-06  7.007353e-06 -5.465868e-06  1.558854e-06
PRE_5A    3.830893e-06  1.013570e-05  1.739417e-05 -1.463438e-05  3.690273e-06
IBOV_1st  7.007353e-06  1.739417e-05  1.023071e-04 -3.704365e-05  2.442711e-05
BRL_1st  -5.465868e-06 -1.463438e-05 -3.704365e-05  5.160562e-05 -9.766693e-06
SPX_1st   1.558854e-06  3.690273e-06  2.442711e-05 -9.766693e-06  3.667363e-05

2) Since the output is 2019-12-11, T+1, I believe that is the estimated Covariance Matrix for 2019-12-12, correct?

Final questions

3) How can I identify which is the last variable used to estimate the covariance matrix? (for a recursive method it's fine to get the last value in the number of observations, but this can't be done with a moving window

4) Is there any way to get the same output of dccforecast in dccroll? The dccforecast ran until 2019-12-12 and the dccroll only until 2019-12-11

If I wasn't clear, please reach me out so I can explain more.

Thank you


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.