Extracting the covariances out of a forecast

128 views Asked by At

I have some trouble extracting the covariances out of a forecast in R. This might be easy for you, but I am a beginner in R:

dcc.fcst = dccforecast(dcc.fit, n.roll=155, n.ahead=1)

print(rcov(dcc.fcst))

and the results I get are in the following format:

$`2015-04-23`
, , T+1

         rpf        rff
rpf 0.0001126362 0.0001125729

rff 0.0001125729 0.0001188316

$`2015-04-24`
, , T+1

        rpf         rff
rpf 0.0001058720 0.0001060763

rff 0.0001060763 0.0001129745

and so on (in total 155 such covariance matrices)...

I tried the formula: rcov(dcc.fcst)$ "%Y-%m-%d"[1,2,]

but it doesn't seem to work.

1

There are 1 answers

0
Martin On
cov.focast.line[i+1] = rcov(dcc.fcst)
outputcov <- matrix(unlist(cov.focast.line), ncol = 2, byrow = TRUE)
cov.focast1 <- c()
for (i in seq(from=2, to=NROW(outputcov), by=2)){
     cov.focast1[i/2] = outputcov[i,1]
}
cov.focast <- data.frame(cov.focast1)