tidyverts / tidyverts/fabletools
Forecasting bug when using lagged predictor and multiple training sets
Open
@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 usingQuotes ~ 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
- 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.
Assessment
This issue has not been assessed yet.