tidyverts / tidyverts/fabletools

Forecasting bug when using lagged predictor and multiple training sets

Open
#326 1 comment 0 reactions 1 assignee View on GitHub

@mitchelloharawild is already working on this.

Since Sep 15, 2021.

Dominant language
R
Stars
98
Forks
37
PR merge metrics
No merged PRs in 30d

Description

Hi all,

I am trying to do cross-validation on a model with lagged predictors. I had some unexpected forecasting results. Below, you'll find an example.

library(fpp3)

insurance_train <- insurance %>%
  stretch_tsibble(.init = 39, .step = 1, .id=".id")

# Commenting out this rule leads to a different forecast for May 2005
# insurance_train <- filter(insurance_train, .id == 2)

fit <- insurance_train %>%
  model(
    lag = ARIMA(Quotes ~ pdq(d = 0) + lag(TVadverts))
  )

insurance_test <- new_data(insurance_train, 1) %>%
  left_join(select(insurance, TVadverts), by='Month')

fit %>%
  forecast(insurance_test)

So far, I noticed that:

  • The issue does not occur if the predictor is not lagged (Quotes ~ pdq(d = 0) + TVadverts).
  • The issue does not occur if the lagged predictor is created manually before stretching the tsibble, thus by adding a variable TVadverts_lag = lag(TVadverts) and using Quotes ~ pdq(d = 0) + TVadverts_lag.

Thanks for creating the fable package and having a look at this issue 🙏.
Timo

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.