I am working on the Chapter 5.2 example in the book: https://otexts.com/fpp3/simple-methods.html, getting errors when testing the code that the instructor is using:
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
-
should be ~
in 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>
Created on 2024-04-13 with reprex v2.1.0