Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Augment & Forecast occasionally does not produce consistent mean for TSLM(log(mr) ~ trend()) model #401

Open
USMortality opened this issue Apr 16, 2024 · 0 comments

Comments

@USMortality
Copy link

USMortality commented Apr 16, 2024

In the below example, using a training set of 2010:2019 produces the following chart:
plot-1
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant