I am trying to accuracy function from fable package. It sometimes gives unexpected errors like this
"Error: Could not find response variable(s) in the fable: Trips"
(This is Example 12 from https://otexts.com/fpp3/toolbox-exercises.html)
Has anyone come across this issue? Here's the code that I am using:
# reprex is one of the (many) packages installed when you install tidyverse
#install.packages("tidyverse")
#install.packages("shiny")
#install.packages("htmltools")
#library(shiny)
#library(miniUI)
# install reprex by itself
library(reprex)
library(fpp3)
#> ── Attaching packages ─────────────────────────────────────────────────────────────────────────────────────── fpp3 0.3 ──
#> ✓ tibble 3.0.1 ✓ tsibble 0.9.0
#> ✓ dplyr 1.0.0 ✓ tsibbledata 0.2.0
#> ✓ tidyr 1.1.0 ✓ feasts 0.1.3
#> ✓ lubridate 1.7.9 ✓ fable 0.2.0
#> ✓ ggplot2 3.3.1
#> ── Conflicts ────────────────────────────────────────────────────────────────────────────────────────── fpp3_conflicts ──
#> x lubridate::date() masks base::date()
#> x dplyr::filter() masks stats::filter()
#> x tsibble::interval() masks lubridate::interval()
#> x dplyr::lag() masks stats::lag()
gc_tourism <- tourism %>% filter(Region=='Gold Coast') %>%
group_by(Purpose) %>%
summarise(Trips=sum(Trips))
gc_train_1 <- gc_tourism %>%
group_by(Purpose) %>%
slice(1:(n()-4))
fit1 <- gc_train_1 %>%
model(SNAIVE=SNAIVE(Trips))
gc_fc_1 <- fit1 %>% forecast(h=4)
gc_fc_1 %>% accuracy(gc_tourism)
#> Error: Could not find response variable(s) in the fable: Trips
Created on 2020-06-28 by the reprex package (v0.3.0)