如此处所述,在测试集中进行单步预测是一种避免随着预测范围增加而不可避免地增加方差的方法。该部分提到了使用已经训练的模型对测试集执行单步预测的方法,用于forecast
包。是否有类似的方法可以使用较新的包对测试数据执行一步预测fable
?例如,这里new_data
描述的参数可能会处理这个问题,但我不确定,因为两者的预测和下面是相同的:h = 24
new_data = x_test
> library(fable)
> library(fabletools)
> x <- USAccDeaths %>%
+ as_tsibble()
> x
# A tsibble: 72 x 2 [1M]
index value
<mth> <dbl>
1 1973 Jan 9007
2 1973 Feb 8106
3 1973 Mar 8928
4 1973 Apr 9137
5 1973 May 10017
6 1973 Jun 10826
7 1973 Jul 11317
8 1973 Aug 10744
9 1973 Sep 9713
10 1973 Oct 9938
# … with 62 more rows
> x_train <- x %>% filter(year(index) < 1977)
> x_test <- x %>% filter(year(index) >= 1977)
> fit <- x_train %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1)))
> fit
# A mable: 1 x 1
arima
<model>
1 <ARIMA(0,1,1)(0,1,1)[12]>
> nrow(x_test)
[1] 24
> forecast(fit, h = 24)$.mean
[1] 7778.052 7268.527 7831.507 7916.845 8769.478 9144.790 10004.816 9326.874 8172.226
[10] 8527.355 8015.100 8378.166 7692.356 7191.343 7751.466 7839.085 8686.833 9062.247
[19] 9918.487 9250.101 8108.202 8463.933 7958.667 8322.497
> forecast(fit, new_data = x_test)$.mean
[1] 7778.052 7268.527 7831.507 7916.845 8769.478 9144.790 10004.816 9326.874 8172.226
[10] 8527.355 8015.100 8378.166 7692.356 7191.343 7751.466 7839.085 8686.833 9062.247
[19] 9918.487 9250.101 8108.202 8463.933 7958.667 8322.497