这儿还有另一个错误信息:<https://stackoverflow.com/questions/44354128/how-to-solve-the-as-data-frame-issue-in-r-forecasting/45992900#45992900>
Error in as.data.frame.default(MSFT.garch11.fcst) :
cannot coerce class "structure("uGARCHforecast", package = "rugarch")" to a data.frame*
使用attributes()
导出该函数预测数据。
> attributes(forc1)[1] %>% data.frame %>% tbl_df
# A tibble: 500 x 6
forecast.n.ahead forecast.N forecast.n.start forecast.n.roll forecast.1991.02.20 forecast.1991.02.20.1
* <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 500 1000 0 0 0.01153849 6.403991e-05
2 500 1000 0 0 0.01085877 1.317389e-04
3 500 1000 0 0 0.01082964 1.925801e-04
4 500 1000 0 0 0.01080124 2.472580e-04
5 500 1000 0 0 0.01077354 2.963971e-04
6 500 1000 0 0 0.01074652 3.405584e-04
7 500 1000 0 0 0.01072018 3.802461e-04
8 500 1000 0 0 0.01069448 4.159135e-04
9 500 1000 0 0 0.01066942 4.479678e-04
10 500 1000 0 0 0.01064497 4.767750e-04
# ... with 490 more rows
> attributes(forc1)[[1]] %>% data.frame %>% tbl_df
# A tibble: 500 x 6
n.ahead N n.start n.roll X1991.02.20 X1991.02.20.1
* <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 500 1000 0 0 0.01153849 6.403991e-05
2 500 1000 0 0 0.01085877 1.317389e-04
3 500 1000 0 0 0.01082964 1.925801e-04
4 500 1000 0 0 0.01080124 2.472580e-04
5 500 1000 0 0 0.01077354 2.963971e-04
6 500 1000 0 0 0.01074652 3.405584e-04
7 500 1000 0 0 0.01072018 3.802461e-04
8 500 1000 0 0 0.01069448 4.159135e-04
9 500 1000 0 0 0.01066942 4.479678e-04
10 500 1000 0 0 0.01064497 4.767750e-04