tidyverts / tidyverts/fabletools
Augment & Forecast occasionally does not produce consistent mean for TSLM(log(mr) ~ trend()) model
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 98
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
In the below example, using a training set of 2010:2019 produces the following chart:
Note the break in the forecasted mean.
This does not happen when either setting training to 2015:2019 or just using lin. trend model: TSLM(mr ~ trend())
Example:
library(fable)
library(tsibble)
library(dplyr)
df <- tibble(
date = 2010:2023,
mr = c(704, 852, 935, 520, 750, 305, 560, 769, 774, 703, 941, 439, 912, 584)
)
df_train <- df |> filter(date %in% 2010:2019)
df_test <- df_bl |> filter(year > 2019)
mdl <- df_train |>
as_tsibble(index = date) |>
model(lm = TSLM(log(mr) ~ trend()))
bl <- mdl |>
augment() |>
rename(.mean = .fitted)
fc <- mdl |> forecast(h = 4)
df_plot <- bind_rows(bl, fc) |> select(date, .mean)
df_plot |> autoplot(.vars = .mean)
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 R example, checking the augment() and forecast(h = 4) outputs for TSLM(log(mr) ~ trend()) trained on 2010:2019. Trace the code paths producing .fitted and .mean, then verify that combining the fitted values and forecasts produces no break in the forecasted mean while the linear-trend case remains consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100