Ric*_*ard 3 statistics runtime-error r time-series
我在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)
Run Code Online (Sandbox Code Playgroud)
我不确定这个子论坛是否是正确的,但它似乎比量化金融论坛更合适.如果是错误的,我道歉.
这个问题是由某种非标准的行为造成的merge.按列名合并时,我们all = FALSE默认使用.但是,当按行名称进行合并时,就像在这种情况下一样,我们似乎拥有all = TRUE并因此MSFT.GSPC.ret包含NA值.
所以,使用其中之一
MSFT.GSPC.ret <- merge(retsys, retibm, all = FALSE)
Run Code Online (Sandbox Code Playgroud)
要么
dcc.fit <- dccfit(dcc.garch11.spec, data = na.omit(MSFT.GSPC.ret))
Run Code Online (Sandbox Code Playgroud)
解决了这个问题.