0

i don't know what's wrong in this code

cement_cv <- aus_production %>%
  slice(1:(n()-4)) %>%
  stretch_tsibble(.init = 5*4, .step = 1)

fc <- cement_cv %>%
  model(ETS(Cement),
        SNAIVE(Cement),
        ) %>%
  forecast(h = "1 year")
fc %>%
  group_by(.id, .model) %>%
  mutate(h = row_number()) %>%
  ungroup() %>%
  accuracy(aus_production, by = c(".model", "h"))

Error in accuracy.default(., aus_production, by = c(".model", "h")) : 
First argument should be a forecast object or a time series.

I would be grateful for your help in pointing out what I am doing wrong.

zx8754
  • 52,746
  • 12
  • 114
  • 209
Garr
  • 1
  • 1
  • 1
    Welcome to stackoverflow. Please refer to https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example to provide a minimum reproducible data for us to help. – Adam Quek May 26 '22 at 09:51
  • Try `accuracy(object = ., x = aus_production, by = c(".model", "h"))` to make explicit that the incoming pipe data (`.`) are the forecast object and `aus_production` is the observed values to compare against. –  May 26 '22 at 09:58
  • You also should not have a comma after `SNAIVE(Cement)` – Andrew Gustar May 26 '22 at 10:26

0 Answers0