2016-11-21 24 views
0

我正在使用包中的DCC Garch rmgarch - 您在上面看到的代码。 根据我的愿望进行的情节调整不适合,因为如果由于我有非常长的时间序列而使用正确的时间序列,所以我不确定是否因为x轴的标题错误。 我必须使用每日和每月的数据,以及每月的数据我得到的问题,看到我的结果。如何从dcc garch获取相关性作为矢量,以及如何绘制多个相关性 - 使用每月数据时也存在错误

为此,我使用rcor(dcc.fit)来显示DCC Garch生成的相关性。

现在我的第一个问题是,如果有可能获得相关的一个载体,而不是你看到我的RCOR(dcc.fit)的结果,否则这将是一个大量的工作?

我的第二个问题是,它只适用于replicate = 2资产,否则我会收到一条错误消息。我必须照顾更多的相关性。 是否有可能获得时间序列相关矩阵?这意味着,要将所有相关性同时计算为一个时间序列并将它们绑定到一个矩阵?

Correlation A&B A&C B&C 

T=1     0,5  -0,5 0,15 
T=2     0,2  -0,3 0,23 
T=3 …… 

My code I used: 

    >garch11.spec = ugarchspec(mean.model = list(armaOrder = c(0,0)), variance.model = list(garchOrder = c(1,1), model = "sGARCH"), distribution.model = "norm") 
    >dcc.garch11.spec = dccspec(uspec = multispec(replicate(2, garch11.spec)), dccOrder = c(1,1), distribution = "mvnorm") 
    >dcc.fit = dccfit(dcc.garch11.spec, data = returns) 
    > rcorr = rcor(dcc.fit) 

#the outcome is above: the error is that this are monthly data and not 
#daily but it shows wrong dates. However, I want to have these correlations as a vector!! 

#1971-07-11 0.1197476 
#1971-07-12 0.1199578 

#further on.. but with right dates! 

, , 1971-07-11 01:00:00 

      Stock_1 Stock_2 
Stock_1 1.0000000 0.1197476 
Stock_2 0.1197476 1.0000000 

, , 1971-07-12 01:00:00 

      Stock_1 Stock_2 
Stock_1 1.0000000 0.1199578 
Stock_2 0.1199578 1.0000000 

, , 1971-07-13 01:00:00 

      Stock_1 Stock_2 
Stock_1 1.0000000 0.1194465 
Stock_2 0.1194465 1.0000000 

, , 1971-07-14 01:00:00 

      Stock_1 Stock_2 
Stock_1 1.00000000 0.07949913 
Stock_2 0.07949913 1.00000000 

, , 1971-07-15 01:00:00 

      Stock_1 Stock_2 
Stock_1 1.00000000 0.08781321 
Stock_2 0.08781321 1.00000000 

Thank you in advance! 

回答

0
#to get time varying correlation 
    rho.est.line <- list() 
    rho.est.line = rcor(dcc.fit, type="R") # plot(rho.est.line[1,2,]) 
    outputcorr <- matrix((rho.est.line[1,2,]), nrow = dim(returns)[1], byrow = TRUE) 
    rho.est = data.frame((outputcorr)) 
    rho.est.zoo = zoo(rho.est, order.by=index(returns[,1])) 
相关问题