fable icon indicating copy to clipboard operation
fable copied to clipboard

Adding -1 does not remove the constant from a VAR model

Open schoulten opened this issue 3 years ago • 0 comments

Hello,

In trying to estimate a VAR model without constant and I noticed that the model is returned with constant even including -1 in the formula specification. The documentation says you have to add -1 or 0 to remove the constant, but adding -1 doesn't work (adding 0 works!).

Any idea what I'm doing wrong? Is it a function problem?

Reproducible example:

library(fable)
#> Warning: package 'fable' was built under R version 4.0.5
#> Loading required package: fabletools

lung_deaths <- cbind(mdeaths, fdeaths) %>%
  as_tsibble(pivot_longer = FALSE)

fit <- lung_deaths %>%
  model(VAR(vars(mdeaths, fdeaths) ~ -1))

report(fit)
#> Series: mdeaths, fdeaths 
#> Model: VAR(5) w/ mean 
#> 
#> Coefficients for mdeaths:
#>       lag(mdeaths,1)  lag(fdeaths,1)  lag(mdeaths,2)  lag(fdeaths,2)
#>                0.777         -0.0617          0.3418         -1.3836
#> s.e.           0.353          0.8562          0.3619          0.8460
#>       lag(mdeaths,3)  lag(fdeaths,3)  lag(mdeaths,4)  lag(fdeaths,4)
#>               0.5249         -0.9750          0.1394         -0.7840
#> s.e.          0.3382          0.7938          0.3453          0.8026
#>       lag(mdeaths,5)  lag(fdeaths,5)  constant
#>              -0.2880          0.0798  998.4724
#> s.e.          0.3294          0.7819  177.3640
#> 
#> Coefficients for fdeaths:
#>       lag(mdeaths,1)  lag(fdeaths,1)  lag(mdeaths,2)  lag(fdeaths,2)
#>               0.2657          0.0963          0.0794         -0.3687
#> s.e.          0.1445          0.3505          0.1481          0.3463
#>       lag(mdeaths,3)  lag(fdeaths,3)  lag(mdeaths,4)  lag(fdeaths,4)
#>               0.1300         -0.2375         -0.0031         -0.1528
#> s.e.          0.1384          0.3249          0.1413          0.3285
#>       lag(mdeaths,5)  lag(fdeaths,5)  constant
#>              -0.1495           0.082  400.0317
#> s.e.          0.1348           0.320   72.5976
#> 
#> Residual covariance matrix:
#>          mdeaths   fdeaths
#> mdeaths 49329.19 18694.675
#> fdeaths 18694.67  8264.509
#> 
#> log likelihood = -777.08
#> AIC = 1606.15    AICc = 1641.25  BIC = 1663.47

sessionInfo()
#> R version 4.0.3 (2020-10-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19043)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252   
#> [3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C                      
#> [5] LC_TIME=Portuguese_Brazil.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] fable_0.3.1           fabletools_0.3.1.9000
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.7           progressr_0.8.0      pillar_1.6.2        
#>  [4] compiler_4.0.3       highr_0.9            R.methodsS3_1.8.1   
#>  [7] R.utils_2.10.1       tools_4.0.3          digest_0.6.27       
#> [10] gtable_0.3.0         lubridate_1.7.10     tsibble_1.0.1       
#> [13] evaluate_0.14        lifecycle_1.0.0      tibble_3.1.4        
#> [16] R.cache_0.15.0       anytime_0.3.9        pkgconfig_2.0.3     
#> [19] rlang_0.4.11         reprex_2.0.0         DBI_1.1.1           
#> [22] yaml_2.2.1           xfun_0.25            fastmap_1.1.0       
#> [25] withr_2.4.2          styler_1.6.2         stringr_1.4.0       
#> [28] dplyr_1.0.7          knitr_1.33           generics_0.1.0      
#> [31] fs_1.5.0             vctrs_0.3.8          grid_4.0.3          
#> [34] tidyselect_1.1.1     glue_1.4.2           R6_2.5.1            
#> [37] fansi_0.5.0          distributional_0.2.2 rmarkdown_2.10      
#> [40] tidyr_1.1.3          ggplot2_3.3.5        farver_2.1.0        
#> [43] purrr_0.3.4          magrittr_2.0.1       scales_1.1.1        
#> [46] backports_1.2.1      ellipsis_0.3.2       htmltools_0.5.2     
#> [49] assertthat_0.2.1     colorspace_2.0-2     utf8_1.2.2          
#> [52] stringi_1.7.4        munsell_0.5.0        crayon_1.4.1        
#> [55] R.oo_1.24.0

Created on 2021-10-27 by the reprex package (v2.0.0)

Thanks!

schoulten avatar Oct 27 '21 20:10 schoulten