从 R 中的 rugarch 包的 GARCH Bootstrap 预测中提取计算值
Extracting computed values from the GARCH Bootstrap Forecast from the rugarch package in R
这是一个相当基础的问题。我使用“rugarch”包中的 'ugarchboot()' 函数来计算时间序列的 'GARCH Bootstrap Forecast',如:
data(sp500ret)
model.garch = ugarchspec(mean.model=list(armaOrder=c(2,1)),variance.model=list(model = "sGARCH"),distribution.model = "norm")
gfit.ru <- ugarchfit(model.garch, sp500ret)
sim <- ugarchforecast(gfit.ru, n.ahead=50)
boot = ugarchboot(gfit.ru, method = c("Partial", "Full")[1], n.ahead = 500, n.bootpred = 500)
show(boot)
*-----------------------------------*
* GARCH Bootstrap Forecast *
*-----------------------------------*
Model : sGARCH
n.ahead : 500
Bootstrap method: partial
Date (T[0]): 2009-01-30
Series (summary):
min q.25 mean q.75 max forecast[analytic]
t+1 -0.110364 -0.012120 0.000062 0.015208 0.078147 0.001151
t+2 -0.152481 -0.013164 -0.000911 0.013793 0.081966 0.001646
t+3 -0.087277 -0.011170 0.000648 0.014108 0.080913 0.001431
t+4 -0.139871 -0.013395 -0.000192 0.015223 0.079184 0.001241
t+5 -0.130759 -0.011849 0.001213 0.015227 0.067346 0.001090
t+6 -0.098652 -0.012557 -0.001205 0.011462 0.098411 0.000971
t+7 -0.166129 -0.010836 0.000816 0.014676 0.067782 0.000877
t+8 -0.159448 -0.011807 -0.000003 0.014219 0.148961 0.000803
t+9 -0.096594 -0.013533 -0.000389 0.012203 0.087792 0.000744
t+10 -0.074158 -0.009883 0.001997 0.013986 0.131996 0.000698
.....................
Sigma (summary):
min q0.25 mean q0.75 max forecast[analytic]
t+1 0.024891 0.024891 0.024891 0.024891 0.024891 0.024891
t+2 0.023712 0.023780 0.024813 0.025114 0.040604 0.024827
t+3 0.022592 0.023017 0.024702 0.025533 0.051992 0.024764
t+4 0.021568 0.022463 0.024458 0.025284 0.050419 0.024701
t+5 0.020639 0.022066 0.024362 0.025503 0.064920 0.024638
t+6 0.019674 0.021694 0.024236 0.025570 0.074341 0.024575
t+7 0.018936 0.021233 0.024098 0.025608 0.070848 0.024513
t+8 0.018287 0.020838 0.023830 0.025387 0.067688 0.024451
t+9 0.017592 0.020403 0.023678 0.025444 0.076089 0.024389
t+10 0.016920 0.020272 0.023570 0.025579 0.073726 0.024328
一切正常,但我很难找到 'min'、'q.25'、'mean'、'q.75' 和 'max' 的位置存储在 'boot' 中的值(类型 'S4' 对象)。谁能告诉我如何找到这些结果?提前谢谢你。
这个非常棘手。我不得不参考 source code.
有一个自定义的 as.data.frame
方法,因此您可以为该系列执行此操作:
t(as.data.frame(boot, which = "series", type = "summary"))
min q.25 mean q.75 max
t+1 -0.1021 -0.01521 -9.76e-04 0.01590 0.0653
t+2 -0.0710 -0.01388 1.84e-03 0.01883 0.0818
t+3 -0.2734 -0.01168 1.43e-03 0.01664 0.0885
t+4 -0.1688 -0.01352 -4.43e-04 0.01434 0.0891
t+5 -0.1081 -0.01087 3.11e-04 0.01397 0.1013
# ... and 495 more rows.
这就是西格玛:
t(as.data.frame(boot, which = "sigma", type = "summary"))
min q0.25 mean q0.75 max
t+1 0.02485 0.02485 0.0249 0.0249 0.0249
t+2 0.02367 0.02375 0.0247 0.0251 0.0387
t+3 0.02255 0.02310 0.0247 0.0255 0.0414
t+4 0.02153 0.02254 0.0247 0.0259 0.0846
t+5 0.02061 0.02216 0.0246 0.0260 0.0807
# ... and 495 more rows.
这是一个相当基础的问题。我使用“rugarch”包中的 'ugarchboot()' 函数来计算时间序列的 'GARCH Bootstrap Forecast',如:
data(sp500ret)
model.garch = ugarchspec(mean.model=list(armaOrder=c(2,1)),variance.model=list(model = "sGARCH"),distribution.model = "norm")
gfit.ru <- ugarchfit(model.garch, sp500ret)
sim <- ugarchforecast(gfit.ru, n.ahead=50)
boot = ugarchboot(gfit.ru, method = c("Partial", "Full")[1], n.ahead = 500, n.bootpred = 500)
show(boot)
*-----------------------------------*
* GARCH Bootstrap Forecast *
*-----------------------------------*
Model : sGARCH
n.ahead : 500
Bootstrap method: partial
Date (T[0]): 2009-01-30
Series (summary):
min q.25 mean q.75 max forecast[analytic]
t+1 -0.110364 -0.012120 0.000062 0.015208 0.078147 0.001151
t+2 -0.152481 -0.013164 -0.000911 0.013793 0.081966 0.001646
t+3 -0.087277 -0.011170 0.000648 0.014108 0.080913 0.001431
t+4 -0.139871 -0.013395 -0.000192 0.015223 0.079184 0.001241
t+5 -0.130759 -0.011849 0.001213 0.015227 0.067346 0.001090
t+6 -0.098652 -0.012557 -0.001205 0.011462 0.098411 0.000971
t+7 -0.166129 -0.010836 0.000816 0.014676 0.067782 0.000877
t+8 -0.159448 -0.011807 -0.000003 0.014219 0.148961 0.000803
t+9 -0.096594 -0.013533 -0.000389 0.012203 0.087792 0.000744
t+10 -0.074158 -0.009883 0.001997 0.013986 0.131996 0.000698
.....................
Sigma (summary):
min q0.25 mean q0.75 max forecast[analytic]
t+1 0.024891 0.024891 0.024891 0.024891 0.024891 0.024891
t+2 0.023712 0.023780 0.024813 0.025114 0.040604 0.024827
t+3 0.022592 0.023017 0.024702 0.025533 0.051992 0.024764
t+4 0.021568 0.022463 0.024458 0.025284 0.050419 0.024701
t+5 0.020639 0.022066 0.024362 0.025503 0.064920 0.024638
t+6 0.019674 0.021694 0.024236 0.025570 0.074341 0.024575
t+7 0.018936 0.021233 0.024098 0.025608 0.070848 0.024513
t+8 0.018287 0.020838 0.023830 0.025387 0.067688 0.024451
t+9 0.017592 0.020403 0.023678 0.025444 0.076089 0.024389
t+10 0.016920 0.020272 0.023570 0.025579 0.073726 0.024328
一切正常,但我很难找到 'min'、'q.25'、'mean'、'q.75' 和 'max' 的位置存储在 'boot' 中的值(类型 'S4' 对象)。谁能告诉我如何找到这些结果?提前谢谢你。
这个非常棘手。我不得不参考 source code.
有一个自定义的 as.data.frame
方法,因此您可以为该系列执行此操作:
t(as.data.frame(boot, which = "series", type = "summary"))
min q.25 mean q.75 max
t+1 -0.1021 -0.01521 -9.76e-04 0.01590 0.0653
t+2 -0.0710 -0.01388 1.84e-03 0.01883 0.0818
t+3 -0.2734 -0.01168 1.43e-03 0.01664 0.0885
t+4 -0.1688 -0.01352 -4.43e-04 0.01434 0.0891
t+5 -0.1081 -0.01087 3.11e-04 0.01397 0.1013
# ... and 495 more rows.
这就是西格玛:
t(as.data.frame(boot, which = "sigma", type = "summary"))
min q0.25 mean q0.75 max
t+1 0.02485 0.02485 0.0249 0.0249 0.0249
t+2 0.02367 0.02375 0.0247 0.0251 0.0387
t+3 0.02255 0.02310 0.0247 0.0255 0.0414
t+4 0.02153 0.02254 0.0247 0.0259 0.0846
t+5 0.02061 0.02216 0.0246 0.0260 0.0807
# ... and 495 more rows.