forecast.ARIMA fc_start being ill defined as NA
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:
- This addition leads to
fc_startbeing defined asNA: https://github.com/tidyverts/fable/blob/master/R/arima.R#L794 - Error then arises in this line due to
NAcomparison withfc_starthere: https://github.com/tidyverts/fable/blob/master/R/arima.R#L804
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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