1

I try to refit an existing fable model to new data to get estimates for unseen data. I am wondering why the constant coefficient changes when I use fable::refit(m, reestimate=F) thats unintuitive to me. The coefficient also changes when I refit the same data again?

If this is the desired behaviour, is there a tidy way to apply a fable model to new data to get estimates?

library(tsibble)
#> 
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, union
library(fable)
#> Loading required package: fabletools

lung_deaths_male <- as_tsibble(mdeaths)
lung_deaths_female <- as_tsibble(fdeaths)

fit <- lung_deaths_male %>%
    model(AR(value ~ 1 + order(3)))

report(fit)
#> Series: value 
#> Model: AR(3) w/ mean 
#> 
#> Coefficients:
#>   constant     ar1      ar2      ar3
#>   606.0584  1.0135  -0.2174  -0.2053
#> 
#> sigma^2 estimated as 57958
#> AIC = -76.58 AICc = -75.98   BIC = -67.47

# refitting to new data without re-estimating the coefficients of the model.
# notice that the constant term changes and the ar-terms remain the same.
fit %>%
    refit(lung_deaths_female, reestimate=FALSE) %>%
    report()
#> Series: value 
#> Model: AR(3) w/ mean 
#> 
#> Coefficients:
#>   constant     ar1      ar2      ar3
#>   108920.8  1.0135  -0.2174  -0.2053
#> 
#> sigma^2 estimated as 1.181e+10
#> AIC = 922.31 AICc = 922.31   BIC = 922.31

# even when refitting the same data as for the original model, the constant
# coefficients change:
fit %>%
    refit(lung_deaths_male, reestimate=FALSE) %>%
    report()
#> Series: value 
#> Model: AR(3) w/ mean 
#> 
#> Coefficients:
#>   constant     ar1      ar2      ar3
#>   262514.8  1.0135  -0.2174  -0.2053
#> 
#> sigma^2 estimated as 6.86e+10
#> AIC = 922.27 AICc = 922.27   BIC = 922.27

# session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.0 (2022-04-22)
#>  os       macOS Big Sur/Monterey 10.16
#>  system   x86_64, darwin17.0
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Paris
#>  date     2022-08-09
#>  pandoc   2.18 @ /Applications/RStudio.app/Contents/MacOS/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package        * version date (UTC) lib source
#>  anytime          0.3.9   2020-08-27 [1] CRAN (R 4.2.0)
#>  assertthat       0.2.1   2019-03-21 [1] CRAN (R 4.2.0)
#>  cli              3.3.0   2022-04-25 [1] CRAN (R 4.2.0)
#>  colorspace       2.0-3   2022-02-21 [1] CRAN (R 4.2.0)
#>  crayon           1.5.1   2022-03-26 [1] CRAN (R 4.2.0)
#>  DBI              1.1.2   2021-12-20 [1] CRAN (R 4.2.0)
#>  digest           0.6.29  2021-12-01 [1] CRAN (R 4.2.0)
#>  distributional   0.3.0   2022-01-05 [1] CRAN (R 4.2.0)
#>  dplyr            1.0.9   2022-04-28 [1] CRAN (R 4.2.0)
#>  ellipsis         0.3.2   2021-04-29 [1] CRAN (R 4.2.0)
#>  evaluate         0.15    2022-02-18 [1] CRAN (R 4.2.0)
#>  fable          * 0.3.1   2021-05-16 [1] CRAN (R 4.2.0)
#>  fabletools     * 0.3.2   2021-11-29 [1] CRAN (R 4.2.0)
#>  fansi            1.0.3   2022-03-24 [1] CRAN (R 4.2.0)
#>  farver           2.1.0   2021-02-28 [1] CRAN (R 4.2.0)
#>  fastmap          1.1.0   2021-01-25 [1] CRAN (R 4.2.0)
#>  fs               1.5.2   2021-12-08 [1] CRAN (R 4.2.0)
#>  generics         0.1.2   2022-01-31 [1] CRAN (R 4.2.0)
#>  ggplot2          3.3.6   2022-05-03 [1] CRAN (R 4.2.0)
#>  glue             1.6.2   2022-02-24 [1] CRAN (R 4.2.0)
#>  gtable           0.3.0   2019-03-25 [1] CRAN (R 4.2.0)
#>  highr            0.9     2021-04-16 [1] CRAN (R 4.2.0)
#>  htmltools        0.5.2   2021-08-25 [1] CRAN (R 4.2.0)
#>  knitr            1.39    2022-04-26 [1] CRAN (R 4.2.0)
#>  lifecycle        1.0.1   2021-09-24 [1] CRAN (R 4.2.0)
#>  lubridate        1.8.0   2021-10-07 [1] CRAN (R 4.2.0)
#>  magrittr         2.0.3   2022-03-30 [1] CRAN (R 4.2.0)
#>  munsell          0.5.0   2018-06-12 [1] CRAN (R 4.2.0)
#>  pillar           1.7.0   2022-02-01 [1] CRAN (R 4.2.0)
#>  pkgconfig        2.0.3   2019-09-22 [1] CRAN (R 4.2.0)
#>  progressr        0.10.1  2022-06-03 [1] CRAN (R 4.2.0)
#>  purrr            0.3.4   2020-04-17 [1] CRAN (R 4.2.0)
#>  R.cache          0.16.0  2022-07-21 [1] CRAN (R 4.2.0)
#>  R.methodsS3      1.8.2   2022-06-13 [1] CRAN (R 4.2.0)
#>  R.oo             1.25.0  2022-06-12 [1] CRAN (R 4.2.0)
#>  R.utils          2.12.0  2022-06-28 [1] CRAN (R 4.2.0)
#>  R6               2.5.1   2021-08-19 [1] CRAN (R 4.2.0)
#>  Rcpp             1.0.8.3 2022-03-17 [1] CRAN (R 4.2.0)
#>  reprex           2.0.1   2021-08-05 [1] CRAN (R 4.2.0)
#>  rlang            1.0.4   2022-07-12 [1] CRAN (R 4.2.0)
#>  rmarkdown        2.14    2022-04-25 [1] CRAN (R 4.2.0)
#>  rstudioapi       0.13    2020-11-12 [1] CRAN (R 4.2.0)
#>  scales           1.2.0   2022-04-13 [1] CRAN (R 4.2.0)
#>  sessioninfo      1.2.2   2021-12-06 [1] CRAN (R 4.2.0)
#>  stringi          1.7.6   2021-11-29 [1] CRAN (R 4.2.0)
#>  stringr          1.4.0   2019-02-10 [1] CRAN (R 4.2.0)
#>  styler           1.7.0   2022-03-13 [1] CRAN (R 4.2.0)
#>  tibble           3.1.7   2022-05-03 [1] CRAN (R 4.2.0)
#>  tidyr            1.2.0   2022-02-01 [1] CRAN (R 4.2.0)
#>  tidyselect       1.1.2   2022-02-21 [1] CRAN (R 4.2.0)
#>  tsibble        * 1.1.1   2021-12-03 [1] CRAN (R 4.2.0)
#>  utf8             1.2.2   2021-07-24 [1] CRAN (R 4.2.0)
#>  vctrs            0.4.1   2022-04-13 [1] CRAN (R 4.2.0)
#>  withr            2.5.0   2022-03-03 [1] CRAN (R 4.2.0)
#>  xfun             0.31    2022-05-10 [1] CRAN (R 4.2.0)
#>  yaml             2.3.5   2022-02-21 [1] CRAN (R 4.2.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.2/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
Created on 2022-08-09 by the reprex package (v2.0.1)

0 Answers0