DCC-GARCH的实现

时间:2016-05-26 11:11:39

标签: r statistics time-series runtime-error

我在R中实现DCC-GARCH时遇到一些问题。当我在R中运行以下代码时,我总是得到相同的错误消息:

  

UseMethod中的错误(“收敛”):     没有适用于“收敛”的方法应用于“try-error”类的对象

不幸的是我不知道如何解决这个问题......

    install.packages("fGarch")
    install.packages("rugarch")
    install.packages("rmgarch")
    library(fGarch)
    library(rmgarch)
    library(rugarch)
    library(tseries)
    library(zoo)

    #Daten runterladen
    ibm <- get.hist.quote(instrument = "DB",  start = "2005-11-21",
                  quote = "AdjClose")
    sys<- get.hist.quote(instrument = "^STOXX50E",  start = "2005-11-21",
                 quote = "AdjClose")

    #Returns
    retibm<-diff(log(ibm))
    retsys<-diff(log(sys))

    # univariate normal GARCH(1,1) for each series
    garch11.spec = ugarchspec(mean.model = list(armaOrder = c(0,0)), 
                      variance.model = list(garchOrder = c(1,1), 
                                            model = "sGARCH"), 
                      distribution.model = "norm")

    # dcc specification - GARCH(1,1) for conditional correlations
    dcc.garch11.spec = dccspec(uspec = multispec( replicate(2, garch11.spec) ), 
                       dccOrder = c(1,1), 
                       distribution = "mvnorm")
    dcc.garch11.spec

    MSFT.GSPC.ret = merge(retsys,retibm)
    plot(MSFT.GSPC.ret)
    dcc.fit = dccfit(dcc.garch11.spec, data = MSFT.GSPC.ret)

我不确定这个子论坛是否是正确的,但它似乎比量化金融论坛更合适。如果是错误的,我道歉。

1 个答案:

答案 0 :(得分:5)

问题是由merge的某种非标准行为引起的。按列名合并时,默认情况下为all = FALSE。但是,在按行名称合并时,如本例所示,我们似乎有all = TRUE,因此MSFT.GSPC.ret包含NA值。

所以,使用

MSFT.GSPC.ret <- merge(retsys, retibm, all = FALSE)

dcc.fit <- dccfit(dcc.garch11.spec, data = na.omit(MSFT.GSPC.ret))

解决了这个问题。