Open USMortality opened 2 months ago
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())
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)
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: