When a formula contains instruments, dot sqaure bracket expansions don’t work for left hand side variables. Without macros in the formula I get the expected multiple estimation results:
library(fixest)
feols(c(mpg, wt) ~ disp + cyl + carb | hp ~ qsec, data = mtcars)
When a formula contains instruments, dot sqaure bracket expansions don’t work for left hand side variables. Without macros in the formula I get the expected multiple estimation results:
With a macro, instead of expanding it to estimate multiple models, LHS variables are expanded into a sum:
I couldn’t find any reference in the docs that this should’t work. However, explicitly requesting a comma expansion and wrapping the macro in
c()
:The same happens with regexes as well:
Created on 2023-02-27 with reprex v2.0.2
Session info
``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.2.2 (2022-10-31 ucrt) #> os Windows 10 x64 (build 19044) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate Hungarian_Hungary.utf8 #> ctype Hungarian_Hungary.utf8 #> tz Europe/Prague #> date 2023-02-27 #> pandoc 3.1 @ C:/scoop/shims/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> cli 3.6.0 2023-01-09 [1] CRAN (R 4.2.2) #> digest 0.6.31 2022-12-11 [1] CRAN (R 4.2.2) #> dreamerr 1.2.3 2020-12-05 [1] CRAN (R 4.2.2) #> evaluate 0.20 2023-01-17 [1] CRAN (R 4.2.2) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.2.2) #> fixest * 0.11.1 2023-01-10 [1] CRAN (R 4.2.2) #> Formula 1.2-5 2023-02-24 [1] CRAN (R 4.2.2) #> fs 1.6.1 2023-02-06 [1] CRAN (R 4.2.2) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.2) #> htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.2.2) #> knitr 1.42 2023-01-25 [1] CRAN (R 4.2.2) #> lattice 0.20-45 2021-09-22 [1] CRAN (R 4.2.2) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.2) #> nlme 3.1-162 2023-01-31 [1] CRAN (R 4.2.2) #> numDeriv 2016.8-1.1 2019-06-06 [1] CRAN (R 4.2.0) #> Rcpp 1.0.10 2023-01-22 [1] CRAN (R 4.2.2) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.2) #> rlang 1.0.6 2022-09-24 [1] CRAN (R 4.2.2) #> rmarkdown 2.20 2023-01-19 [1] CRAN (R 4.2.2) #> sandwich 3.0-2 2022-06-15 [1] CRAN (R 4.2.2) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.2) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.2) #> xfun 0.37 2023-01-31 [1] CRAN (R 4.2.2) #> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.2.2) #> zoo 1.8-11 2022-09-17 [1] CRAN (R 4.2.2) #> #> [1] C:/scoop/apps/r-release/4.2.2/library #> #> ────────────────────────────────────────────────────────────────────────────── ```