fable icon indicating copy to clipboard operation
fable copied to clipboard

Different fitted models yield identical forecasts

Open aridf opened this issue 3 years ago • 1 comments

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!

aridf avatar Nov 12 '21 17:11 aridf

Cross-posted to stackoverflow here in case this is just a coding mistake, in which case I will close this issue.

aridf avatar Nov 12 '21 17:11 aridf