rfinancebayesiancoda

Extraction of correlation matrix, R, from BayesDCCgarch


I am currently experimenting with the bayesDCCgarch package and have been looking to extract bivariate conditional correlations from the estimation of the model.

The output of the function only delivers the variance, covariance matrix H_t, which consists out of H=DRD (where D_t comes from the conditional variance estimate of the univariate garch model). I am looking for the R matrix

I have had a look in the code on the github here and have seen that in the script, bayesDccGarch.c they do calculate the correlation matrix R (lines 291 - 300)

// compute the R matrix
    for(i = 0; i < k; i++){
        hiit = omega[i];// /(1.0-beta[i]); // H_{ii,1}
        MEs[i][0]  = y[0][i]/sqrt(hiit);
        for(t = 1; t < n; t++){
            hiit = omega[i] + alpha[i]*y[t-1][i]*y[t-1][i] + beta[i]*hiit; // H_{ii,t}
            MEs[i][t]  = y[t][i]/sqrt(hiit); // Standard Errors
        }
    }   
    mcov(n, k, MEs, R); // compute the R matrix

Any help how I could plot correlation matrix R rather than the estimated volatilities for each of the series as in the code below:

 library(bayesDccGarch)
 data(DaxCacNik)  
 mY<-DaxCacNik[,1:2]
 out = bayesDccGarch(mY, nSim=1000)
 plotVol(mY, out$H[,c("H_1,1","H_2,2")], c("DAX","CAC40"))

I am looking to compare the correlation construction to that of the dccfit function in the rmgarch library.


Solution

  • After haven spoken to the author of the package, the correct answer for the extraction of the correlation is indeed using the H matrix along withcov/sqrt(var)sqrt(var):

     library(bayesDccGarch)
     data(DaxCacNik)  
     mY<-DaxCacNik[,1:2]
     out = bayesDccGarch(mY, nSim=10000)
     R<-out$H[,("H_2,1")]/sqrt(out$H[,("H_1,1")]*out$H[,("H_2,2")])