我为以下模拟数据拟合了ARMA-GARCH模型,并最终获得了自举预测间隔。我在R中使用了rugrach
包。
ar.sim<-arima.sim(model=list(ar=c(.9,-.2),ma=c(-.7,.1)),n=100)
logr=diff(log(na.omit(ar.sim)))
require(rugrach)
gar<-ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(2, 1)),
mean.model = list(armaOrder = c(2, 1)),
distribution.model = "norm");
fitg=ugarchfit(spec = gar,data = ar.sim,solver = "hybrid");
garch11.boot = ugarchboot(fitg, method="Partial",
n.ahead=10, n.bootpred=2000)
我的引导程序输出结果如下,我的问题基于此输出,
> garch11.boot
*-----------------------------------*
* GARCH Bootstrap Forecast *
*-----------------------------------*
Model : sGARCH
n.ahead : 10
Bootstrap method: partial
Date (T[0]): 0100-01-01
Series (summary):
min q.25 mean q.75 max forecast[analytic]
t+1 -1.5418 -0.60011 0.111638 0.78600 2.9529 0.12522
t+2 -1.8665 -0.66265 0.110356 0.74133 3.1840 0.12857
t+3 -1.9302 -0.61371 0.111750 0.73367 3.4751 0.10131
t+4 -1.8828 -0.64614 0.104376 0.75553 3.2405 0.11716
t+5 -1.8306 -0.61477 0.135969 0.76970 3.4603 0.10583
t+6 -1.8864 -0.65527 0.130858 0.74737 3.4491 0.11362
t+7 -1.9581 -0.61335 0.122836 0.75270 3.1523 0.10822
t+8 -1.8804 -0.61070 0.114942 0.74431 3.3355 0.11196
t+9 -1.8663 -0.70012 0.061826 0.70271 3.2432 0.10937
t+10 -1.9256 -0.67817 0.055261 0.64646 3.3439 0.11116
.....................
Sigma (summary):
min q0.25 mean q0.75 max forecast[analytic]
t+1 0.90218 0.90218 0.90218 0.90218 0.90218 0.90218
t+2 0.90107 0.90107 0.90107 0.90107 0.90107 0.90107
t+3 0.89997 0.89997 0.89997 0.89997 0.89997 0.89997
t+4 0.89887 0.89887 0.89887 0.89887 0.89887 0.89887
t+5 0.89777 0.89777 0.89777 0.89777 0.89777 0.89777
t+6 0.89667 0.89667 0.89667 0.89667 0.89667 0.89667
t+7 0.89557 0.89557 0.89557 0.89557 0.89557 0.89557
t+8 0.89447 0.89447 0.89447 0.89447 0.89447 0.89447
t+9 0.89337 0.89337 0.89337 0.89337 0.89337 0.89337
t+10 0.89228 0.89228 0.89228 0.89228 0.89228 0.89228
.....................
我的问题是如何从此输出提取下限和上限列(q0.25和q0.75)?
我使用了str(garch11.boot)
,但找不到与此相关的任何内容。
答案 0 :(得分:1)
数据在garch11.boot@forc
之内。
您可以通过运行以下代码来提取它:
sig = sigma(garch11.boot@forc)
ser = fitted(garch11.boot@forc)
zs = cbind(t(as.data.frame(garch11.boot, which = "sigma", type = "summary")), sig)
zr = cbind(t(as.data.frame(garch11.boot, which = "series", type = "summary")), ser)
zr[, c(2, 4)]
zs[, c(2, 4)]
说明:
获得此代码的一种方法是对该程序包的print()
方法进行反向工程,您将在其中看到所需的结果。
您可以在这里找到打印方法:
https://github.com/cran/rugarch/blob/1ad7e9ddb5ebaea9b191eb8326353334196f3ebc/R/rugarch-methods.R#L1607。
通过该代码,您将进入上面提供的代码。