tidyverts / tidyverts/fable

forecast.ARIMA fc_start being ill defined as NA

Open
#378 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
588
Forks
71
Avg merge
1h 58m
Merged PRs (30d)
1

Description

Monthly series with yearmonth indexed tsibble. Loading all libraries through fpp3.

The error goes away if I filter for the series to end in not May. It seems that adding 1 to a yearmonth in May leads to NA. The issue might be deeper and related to the yearmonth function itself. To recreate the issue I have to use: yearmonth("1995 Jun") + 1 since running yearmonth("1995 May") outputs 1995 Apr and running yearmonth("1995 Jun") outputs 1995 May. UPDATE: idk anymore, it seems different random yearmonths +1 can lead to NA

Reprex:

# forecast.ARIMA error reprex
library(fpp3)

data_url <- "https://docs.google.com/spreadsheets/d/1s7LfGmAv7EvpqEMe2RHcSPPKSNnBj8HmnvaDDd3A6Yw/export?format=csv"
hotels <- read.csv(data_url) %>%
  mutate(month = yearmonth(month)) %>%
  tsibble(index = month)

# No error if this filter performed:
# hotels <- hotels %>% 
#   filter_index(. ~ "1994 Dec")

hotels %>%
  model(ARIMA(revenue)) %>%
  forecast(h = 12)

hotels %>%
  model(ARIMA(revenue)) %>%
  forecast(h = 12)

Error message

Error in `mutate()`:
! Problem while computing `ARIMA(revenue) =
  (function (object, ...) ...`.
   Caused by error in `if (unclass(new_data)[[index_var(new_data)]][1] != fc_start) ...`:
     ! missing value where TRUE/FALSE needed
   Run `rlang::last_error()` to see where the error occurred.

Lines in forecast.ARIMA that lead to the error:

Relevant package and R versions

R.version$version.string
# [1] "R version 4.2.2 (2022-10-31)"
packageVersion("fable")
# [1] ‘0.3.2’
packageVersion("fpp3")
# [1] ‘0.4.0’

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied fpp3 reprex and inspect R/arima.R at the reported lines 794 and 804. Trace the yearmonth addition that produces fc_start and verify the forecast.ARIMA path no longer reaches an NA comparison while forecasting completes for the provided hotels data.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.