我正在研究书中第5.2章的示例:https://otexts.com/fpp3/simple-methods.html,在测试讲师正在使用的代码时出现错误:
filter(!is.na(Bricks)) %>%
model(
Seasonal_naive = SNAIVE(Bricks),
Naive = NAIVE(Bricks),
Drift = RW(Bricks - drift()),
Mean = MEAN(Bricks)
) ```
Here below is an extract of the error message from RStudio whenever I run the code:
> Error in x[[1]] : subscript out of bounds
看起来像是一个拼写错误:
-
应该是~
中的RW(Bricks ~ drift())
。
library(fpp3)
bricks <- aus_production |>
filter_index("1970 Q1" ~ "2004 Q4") |>
select(Bricks)
bricks |>
filter(!is.na(Bricks)) |>
model(
Seasonal_naive = SNAIVE(Bricks),
Naive = NAIVE(Bricks),
Drift = RW(Bricks ~ drift()),
Mean = MEAN(Bricks)
)
#> # A mable: 1 x 4
#> Seasonal_naive Naive Drift Mean
#> <model> <model> <model> <model>
#> 1 <SNAIVE> <NAIVE> <RW w/ drift> <MEAN>
创建于 2024-04-13,使用 reprex v2.1.0