tidyverts / tidyverts/fable

Different fitted models yield identical forecasts

Open
#354 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
588
Forks
71
Avg merge
1h 58m
Merged PRs (30d)
1

Description

I'm trying to fit and forecast TSLM models with different time-t predictors added alongside the trend... for reasons I don't understand, several of the models yield identical predictions even though the the input test data appears different, and the coefficients in the models themselves appear different. Almost certainly this an error on my part.. let me know what's going wrong!

reprexdata.csv

suppressPackageStartupMessages({
    library(tidyverse)
    library(tsibble)
    library(fable)
    library(feasts)
})

proj_tract <- read_csv("path_to_reprexdata")

proj_tract <- as_tsibble(proj_tract, key = tractid, index = year)

train <- proj_tract %>%
    filter(year < 2019) 

test <- proj_tract %>%
    filter(year >= 2019) 

fit <- train %>%
    model(
        trend_only = TSLM(log(chh) ~ trend()),
        trend_w_dar = TSLM(log(chh) ~ trend() + log(ig_count_imptd)),
        trend_w_da1 = TSLM(log(chh) ~ trend() + log(prd_1)),
        trend_w_da2 = TSLM(log(chh) ~ trend() + log(prd_2)),
        trend_w_da3 = TSLM(log(chh) ~ trend() + log(prd_3)),
        trend_w_da4 = TSLM(log(chh) ~ trend() + log(prd_4)),
        trend_w_da5 = TSLM(log(chh) ~ trend() + log(prd_glmnet))
    )

fc <- forecast(
    fit,
    new_data = test
) %>% 
    hilo(.95)

res <- fc %>% 
    as_tibble() %>%
    rename("proj" = ".mean", "model" = ".model") %>%
    select(model, proj, lchh) %>%
    pivot_wider(names_from = model, values_from = proj)
head(res)

A subset of these models yield identical predictions -- help me understand why!

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.

Research direction

Start by running the supplied R reprex with reprexdata.csv, focusing on the TSLM model definitions and the forecast(fit, new_data = test) call. Compare the predictor columns in test with the fitted models and inspect the resulting forecasts. Done means explaining why the models produce identical predictions and identifying the relevant correction or expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
analytics, data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.