alpha(1%) alpha(5%) realized
2010-12-21 -0.01509998 -0.009001583 -2.035892e-03
2010-12-22 -0.01440173 -0.008577771 9.735154e-04
2010-12-23 -0.01389563 -0.008287957 1.858982e-03
2010-12-27 -0.01376369 -0.008223168 -1.597613e-03
2010-12-28 -0.01337600 -0.007983994 2.548457e-04
2010-12-29 -0.01306351 -0.007802134 -2.021994e-03
嗨,上面是我正在使用的数据。当我尝试使用代码
绘制预测时plot(modelroll@forecast$VaR[,"alpha(1%)"])
其中modelroll @ forecast $ VaR是上面的数据,我只是得到x轴上的观察数,而我需要日期。为什么R不承认日期。当我绘制返回系列时,它确实识别x轴上的日期。还有一个问题我如何使用一个列提取特定行,例如使用循环对前10次观察的alpha(1%)列。我试过了
modelroll@forecast$VaR[1:10,"alpha(1%)"]
但它不起作用。提前谢谢。
dput(head(modelroll@forecast$VaR))
structure(list(`alpha(1%)` = c(-0.0150999800078312, -0.0144017267128711,
-0.0138956320928591, -0.0137636901290749, -0.0133759968008841,
-0.0130635141114229), `alpha(5%)` = c(-0.00900158285193088, -0.0085777709430231,
-0.0082879574620513, -0.00822316834000325, -0.00798399426075919,
-0.0078021335073256), realized = c(-0.0020358922408686, 0.000973515436500283,
0.00185898240838507, -0.00159761300810324, 0.000254845717341201,
-0.00202199418958748)), .Names = c("alpha(1%)", "alpha(5%)",
"realized"), row.names = c("2010-12-21", "2010-12-22", "2010-12-23",
"2010-12-27", "2010-12-28", "2010-12-29"), class = "data.frame")
答案 0 :(得分:1)
假设df
是数据集,
m1 <- as.matrix(df)
d <- as.Date(row.names(m1))
matplot(d, m1, pch=1, xaxt='n')
axis(1, at=d, labels=d)
legend(x='topright', y=3.5, c(' alpha(1%)', ' alpha(5%)', ' realized'),
pch='15r', col=2:4)
此外,
m1[1:3, 'alpha(1%)']
#2010-12-21 2010-12-22 2010-12-23
#-0.01509998 -0.01440173 -0.01389563