问:R 的
fable
包中分层协调预测的引导模拟预测路径到底是什么?令我惊讶的是,它们并不是引导程序模拟基线预测并协调每个预测的结果,如下所示。
library(fpp3)
tourism_states <- tourism |>
aggregate_key(State, Trips = sum(Trips))
tourism_states |>
model(ets = ETS(Trips)) |>
reconcile(bu = bottom_up(ets)) |>
forecast()
#> # A fable: 144 x 5 [1Q]
#> # Key: State, .model [18]
#> State .model Quarter Trips .mean
#> <chr*> <chr> <qtr> <dist> <dbl>
#> 1 ACT ets 2018 Q1 N(701, 7651) 701.
#> 2 ACT ets 2018 Q2 N(717, 8032) 717.
#> 3 ACT ets 2018 Q3 N(734, 8440) 734.
#> 4 ACT ets 2018 Q4 N(750, 8882) 750.
#> 5 ACT ets 2019 Q1 N(767, 9368) 767.
#> 6 ACT ets 2019 Q2 N(784, 9905) 784.
#> 7 ACT ets 2019 Q3 N(800, 10503) 800.
#> 8 ACT ets 2019 Q4 N(817, 11171) 817.
#> 9 ACT bu 2018 Q1 N(701, 7651) 701.
#> 10 ACT bu 2018 Q2 N(717, 8032) 717.
其中,如我所料,第 1 行中的
.mean
值等于第 9 行中的值,第 2 行中的值等于第 10 行中的值,依此类推。换句话说,层次结构最低级别的基线预测 ets
(此处为 State
)与自下而上的协调预测 bu
相同。
但是接下来的事情让我感到惊讶。
tourism_states |>
model(ets = ETS(Trips)) |>
reconcile(bu = bottom_up(ets)) |>
forecast(boostrap=TRUE,times=1)
# # A fable: 144 x 5 [1Q]
# # Key: State, .model [18]
# State .model Quarter Trips .mean
# <chr*> <chr> <qtr> <dist> <dbl>
# 1 ACT ets 2018 Q1 sample[1] 650.
# 2 ACT ets 2018 Q2 sample[1] 671.
# 3 ACT ets 2018 Q3 sample[1] 519.
# 4 ACT ets 2018 Q4 sample[1] 631.
# 5 ACT ets 2019 Q1 sample[1] 824.
# 6 ACT ets 2019 Q2 sample[1] 643.
# 7 ACT ets 2019 Q3 sample[1] 647.
# 8 ACT ets 2019 Q4 sample[1] 810.
# 9 ACT bu 2018 Q1 sample[1] 744.
# 10 ACT bu 2018 Q2 sample[1] 568
自下而上的预测不再与基线预测相同。我预计在这种情况下引导意味着构建基线预测的预测样本路径,然后“每一个”将自下而上地进行协调。但这显然没有发生。 那么,在引导的背景下,这些自下而上的预测
bu
到底是什么?它们是从基线预测中采样样本内拟合残差并将其应用于自下而上的预测的结果,人们不会期望这种自下而上的模拟等于基线模拟。
ets
和
bu
模型的基本预测包含不同的基本引导样本。如果您为引导样本设置seed
(从
generate()
获得),您将找到预期的结果。library(fpp3)
tourism_states <- tourism |>
aggregate_key(State, Trips = sum(Trips))
tourism_states |>
model(ets = ETS(Trips)) |>
reconcile(bu = bottom_up(ets)) |>
forecast(bootstrap=TRUE,times=1,seed=1)
#> # A fable: 144 x 5 [1Q]
#> # Key: State, .model [18]
#> State .model Quarter Trips .mean
#> <chr*> <chr> <qtr> <dist> <dbl>
#> 1 ACT ets 2018 Q1 sample[1] 701.
#> 2 ACT ets 2018 Q2 sample[1] 799.
#> 3 ACT ets 2018 Q3 sample[1] 809.
#> 4 ACT ets 2018 Q4 sample[1] 861.
#> 5 ACT ets 2019 Q1 sample[1] 891.
#> 6 ACT ets 2019 Q2 sample[1] 983.
#> 7 ACT ets 2019 Q3 sample[1] 914.
#> 8 ACT ets 2019 Q4 sample[1] 814.
#> 9 ACT bu 2018 Q1 sample[1] 701.
#> 10 ACT bu 2018 Q2 sample[1] 799.
#> # i 134 more rows
创建于 2024-05-11,使用