rugarch(ugarchroll)-样本外预测的日历日期与初始样本外期不同

4
我正在尝试使用R语言中rugarch包中的ugarchroll函数,利用ARCH(1)模型生成每日滚动的样本外预测。然而,这些样本外预测与原始的样本外收益序列具有不同的日历日期,因此不匹配。
为了澄清,我的样本内期从2000-01-05到2004-08-06(1,000个观测值),而样本外期从2004-08-09到2018-03-27(3,078个观测值)。
我的样本数据如下:
> show(Data_v016_inclEM)
# A tibble: 4,078 x 68
   date1          t sp_op sp_cp sp_high sp_low mxx_op mxx_cp mxx_high mxx_low hsi_op hsi_cp hsi_high hsi_low ks_op
   <date>     <dbl> <dbl> <dbl>   <dbl>  <dbl>  <dbl>  <dbl>    <dbl>   <dbl>  <dbl>  <dbl>    <dbl>   <dbl> <dbl>
 1 2000-01-05     1 1396. 1402.   1413.  1378.  6675.  6764     6781.   6524. 16609. 15847.   16609.  15688. 1007.
 2 2000-01-06     2 1399. 1403.   1412.  1392.  6764.  6752.    6822.   6743. 15942. 15153.   15971.  14764. 1014.
 3 2000-01-07     3 1403. 1441.   1441.  1401.  6769.  7047.    7054.   6769. 15329. 15406.   15514.  15109.  949.
 4 2000-01-10     4 1441. 1457.   1464.  1441.  7048.  7334.    7337.   7048. 15631  15848.   16065.  15631   980.
 5 2000-01-11     5 1457. 1438.   1459.  1434.  7332.  7143.    7363.   7078. 15981. 15862.   16196.  15736.  992.
 6 2000-01-12     6 1439. 1432.   1443.  1427.  7143.  7174.    7174.   7091. 15692. 15714.   15744.  15546.  958.
 7 2000-01-13     7 1432. 1450.   1454.  1432.  7174.  7275.    7426.   7174. 15763. 15634.   15861.  15459.  955.
 8 2000-01-14     8 1450. 1464.   1473   1450.  7279.  7381.    7394.   7279. 15742. 15542.   15863.  15322.  959.
 9 2000-01-18     9 1465. 1455.   1465.  1451.  7447.  7304.    7447.   7302. 15576. 15789.   15801.  15508.  992.
10 2000-01-19    10 1452. 1456.   1461.  1449.  7303.  7171.    7311.   7171. 15719. 15275.   15719.  15192.  969.
# ... with 4,068 more rows, and 53 more variables

我使用以下代码执行每日滚动的ARCH(1)预测:

ARCH_1 <- ugarchspec(variance.model = list(garchOrder = c(1,0)),mean.model = list(armaOrder = c(0,0)))
Fit_ARCH_1 <- ugarchfit(spec = ARCH_1, data = Data_v016_inclEM$ret_sp_index, out.sample = 3078, solver = "hybrid")
Var_ARCH_1 <- Fit_ARCH_1@fit$var

# Out-of-sample rolling forecasts #    
cluster <- makePSOCKcluster(10)
          CVAR_ARCH1_h1 <- ugarchroll(ARCH_1, Data_v016_inclEM$ret_sp_index, n.ahead = 1, forecast.length = 3078, n.start = 1000, refit.every = 1, refit.window = "moving", window.size = 1000, solver = "hybrid", solver.control = list(tol = 1e-6, trace = 1), keep.coef = TRUE, fit.control = list(scale = 1))
          CVAR_ARCH1_h1 <- resume(CVAR_ARCH1_h1, solver = "gosolnp")
          show(CVAR_ARCH1_h1)
          stopCluster(cluster)
          View(CVAR_ARCH1_h1@forecast$density)
          report(CVAR_ARCH1_h1)
          report(CVAR_ARCH1_h1, type = "fpm")

每日滚动的ARCH(1)预测与上述的样本外期间从不同的日历日期开始。如下结果所示,它创建了一个从1972-09-281981-03-02的日期条目。

> show(CVAR_ARCH1_h1)

*-------------------------------------*
*              GARCH Roll             *
*-------------------------------------*
No.Refits       : 3078
Refit Horizon   : 1
No.Forecasts    : 3078
GARCH Model     : sGARCH(1,0)
Distribution    : norm 

Forecast Density:
                         Mu  Sigma Skew Shape Shape(GIG) Realized
1972-09-28 01:00:00 -0.0274 0.0113    0     0          0   0.0014
1972-09-29 01:00:00 -0.0261 0.0238    0     0          0   0.0125
1972-09-30 01:00:00 -0.0256 0.0341    0     0          0  -0.0031
1972-10-01 01:00:00 -0.0249 0.0218    0     0          0  -0.0115
1972-10-02 01:00:00 -0.0004 0.0138    0     0          0   0.0015
1972-10-03 01:00:00 -0.0313 0.0328    0     0          0   0.0137

..........................
                       Mu  Sigma Skew Shape Shape(GIG) Realized
1981-02-25 01:00:00 8e-04 0.0062    0     0          0  -0.0124
1981-02-26 01:00:00 8e-04 0.0107    0     0          0  -0.0018
1981-02-27 01:00:00 5e-04 0.0064    0     0          0  -0.0255
1981-02-28 01:00:00 4e-04 0.0180    0     0          0  -0.0212
1981-03-01 01:00:00 7e-04 0.0158    0     0          0   0.0269
1981-03-02 01:00:00 8e-04 0.0184    0     0          0  -0.0175

Elapsed: 26.66044 mins

那么,这些样本外的预测日期为什么与上述样本外期间的日历日期不匹配呢?我可能错过了哪些步骤才能正确地进行这些滚动预测?如何解决这个小问题?
非常感谢你的帮助!
1个回答

0
你需要将数据从 tibble 转换为 xts 对象。你可以使用 timetk 库中的 tk_xts 函数。例如,
library(timetk)
Data_v016_inclEM <- tk_xts(Data_v016_inclEM,  date_col = Data_v016_inclEM$date1)

查看这篇Stackoverflow帖子


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接