plot(dcc.fit)不绘图(rmgarch包)

时间:2017-12-10 20:41:17

标签: r

structure(c(-0.0343636188400374, 0.0104885242596549, -0.0340719994524541, 
0.0129834504230537, 0.00726425460144453, -0.0259456191414236, 
-0.0331137622240925, 0.0187248508043534, 0.0403345305611627, 
0.0269175013880338, -0.0748170288918457, -0.0093898221229205, 
-0.0214547692070148, -0.0243910256435065, 0.0153138591890918, 
-0.0340067862273159, -0.00630881036315545, -0.00507636532488531, 
-0.00382393403377179, 0.0504309696315595, -0.0390991755058661, 
0.00192033767176891, 0.000955221868328415, 0.0267299500582903, 
0.0111278249512576, -0.0131485767905737, -0.00439601996101047, 
0.0120962453648144, 0.0106147630153357, -0.0068555164525268, 
0.000522156347618541, -0.00712061248542284, -0.00291656817789931, 
-0.0280225841963713, 0.00604648360431792, -0.00422161942814814, 
-0.00394620386197975, -0.0278408131523173, 0.0249048507060516, 
0.0105717406599295), class = c("xts", "zoo"), .indexCLASS = "Date", .indexTZ = "UTC", tclass = "Date", tzone = "UTC", src = "yahoo", updated = structure(1512938276.80954, class = c("POSIXct", 
"POSIXt")), ret_type = "log", index = structure(c(946944000, 
947030400, 947116800, 947203200, 947462400, 947548800, 947635200, 
947721600, 947808000, 948153600, 948240000, 948326400, 948412800, 
948672000, 948758400, 948844800, 948931200, 949017600, 949276800, 
949363200), tzone = "UTC", tclass = "Date"), .Dim = c(20L, 2L
), .Dimnames = list(NULL, c("MSFT", "GSPC")))

我使用rugarch和rmgarch来规范并将DCC模型与我的数据相匹配。模型生成成功,但我无法生成图表。这是我的代码片段:

symbol.vec = c("MSFT", "^GSPC")
getSymbols(symbol.vec, from ="2000-01-03", to = "2012-04-03")
colnames(MSFT)
start(MSFT)
end(MSFT)

# extract adjusted closing prices
MSFT = MSFT[, "MSFT.Adjusted", drop=F]
GSPC = GSPC[, "GSPC.Adjusted", drop=F]

# plot prices
plot(MSFT)
plot(GSPC)

# calculate log-returns for GARCH analysis
MSFT.ret = CalculateReturns(MSFT, method="log")
GSPC.ret = CalculateReturns(GSPC, method="log")


# remove first NA observation
MSFT.ret = MSFT.ret[-1,]
GSPC.ret = GSPC.ret[-1,]
colnames(MSFT.ret) ="MSFT"
colnames(GSPC.ret) = "GSPC"

# create combined data series
MSFT.GSPC.ret = merge(MSFT.ret,GSPC.ret)

# plot returns
plot(MSFT.ret)
plot(GSPC.ret)

# scatterplot of returns
plot( coredata(GSPC.ret), coredata(MSFT.ret), xlab="GSPC", ylab="MSFT",
      type="p", pch=16, lwd=2, col="blue")
abline(h=0,v=0)


# 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

dcc.fit = dccfit(dcc.garch11.spec, data = MSFT.GSPC.ret)
class(dcc.fit)
slotNames(dcc.fit)
names(dcc.fit@mfit)
names(dcc.fit@model)

# many extractor functions - see help on DCCfit object
# coef, likelihood, rshape, rskew, fitted, sigma, 
# residuals, plot, infocriteria, rcor, rcov
# show, nisurface

# show dcc fit
dcc.fit

# plot method
plot(dcc.fit)
# Make a plot selection (or 0 to exit): 
#   
# 1:   Conditional Mean (vs Realized Returns)
# 2:   Conditional Sigma (vs Realized Absolute Returns)
# 3:   Conditional Covariance
# 4:   Conditional Correlation
# 5:   EW Portfolio Plot with conditional density VaR limits

我选择哪一个并不重要,我得到的输出不存在:

enter image description here

我做错了什么?

P.S;我正在使用Rstudio和Rversion 3.4.2

0 个答案:

没有答案