fPortfolio和DCC garch

时间:2019-09-26 18:47:02

标签: r finance quantitative-finance portfolio r-portfolioanalytics

因此,我正在尝试将DCC贵族的预测传递到投资组合中,以做进一步有趣的事情,例如计算有效边界等。

dcc.garch11.spec
dcc.fit= dccfit(dcc.garch11.spec, data =Dat) 

#Forecasting 
dcc.fit.focast=dccforecast(dcc.fit, n.ahead = 1, n.roll = 0)
print(dcc.fit.focast)


R_focast <- dcc.fit.focast@mforecast$R 
H_focast<-dcc.fit.focast@mforecast$H 

#Portfolio Optimization (Use the forecasted variance covariance matrix)

#install.packages("timeSeries") need to make it timeSeries
library(timeSeries)
tsDat<-as.timeSeries(Dat) 

#install.packages("fPortfolio")
library(fPortfolio)

covtEstimator <- function (x, data,spec) {x.mat = as.matrix(x) 
list(mu = dcc.fit.focast@model$mu, Sigma = H_focast)}

covtSpec <- portfolioSpec()

setEstimator(covtSpec) <- "covtEstimator"

setNFrontierPoints(covtSpec) <- 5

covtFrontier <- portfolioFrontier(data = tsDat, spec = covtSpec)

但是,出现以下错误:

Error in dimnames(x) <- dn : 
  length of 'dimnames' [1] not equal to array extent

0 个答案:

没有答案