I am trying to run different sets of regression models with fixed effects uisng feols from the fixest package in R. I run into issues where R forces me to compute the interaction of the reference level from a factor. This shouldn't happen, as the factor's reference level is inherently collinear, which is why no base effect is calculated for it.
My data and code are as follows:
library(fixest)
library(tidyverse)
df =
structure(list(DV = c(0.666666666666667, 0, 0.333333333333333,
0.333333333333333, 0, 0, 0.333333333333333, 0, 0.333333333333333,
1, 0, NA, 1, 0, 0, 0, 0.333333333333333, 0.333333333333333, 1,
0, 0.666666666666667, NA, 0.666666666666667, 0.333333333333333,
0.333333333333333, 0.333333333333333, 0.333333333333333, 0, 1,
0.666666666666667, 0.666666666666667, 0, 0, 0.666666666666667,
0, 0.333333333333333, 0, 0, 0.333333333333333, 0.333333333333333,
0.666666666666667, 0.666666666666667, 0, 0, 1, 0, 0.333333333333333,
NA, 0.666666666666667, 0.333333333333333, 0, 0, 0, 0.333333333333333,
0.666666666666667, 0, 0.666666666666667, 0, 0.333333333333333,
0, 0, NA, 0.333333333333333, 0, 0.666666666666667, 0, 0.333333333333333,
0.333333333333333, 0, 0.333333333333333, 0.333333333333333, 0.333333333333333,
0, NA, 0, 0, 0.333333333333333, 0, 0.333333333333333, 0, 0.666666666666667,
1, 0, 0, 0.333333333333333, 0, 0.666666666666667, 0, 0.666666666666667,
0.333333333333333, 0, 0.333333333333333, 0.333333333333333, 0.333333333333333,
0, 1, 0, 0.333333333333333, 0, 0, 0.333333333333333, 0, 0.666666666666667,
0.666666666666667, 0, 0, 0.666666666666667, 1, 0.666666666666667,
0, 0.333333333333333, 0, 0.666666666666667, 0.333333333333333,
0.333333333333333, 0, 0, NA, 0.333333333333333, 0, 0.333333333333333,
NA, 0, 0, 0.333333333333333, 1, NA, 0.333333333333333, 0.333333333333333,
0, 0.666666666666667, 0.333333333333333, 0, 0.666666666666667,
NA, 0.333333333333333, 0, 0.333333333333333, 0.333333333333333,
0.666666666666667, 0, 0.666666666666667, 0.333333333333333, 0,
0.666666666666667, 0.333333333333333, 0.666666666666667, 0, 0,
0.333333333333333, 0, 0.333333333333333, 0.333333333333333, 0,
0, 0.333333333333333, 0, 0.666666666666667, 0, 0.333333333333333,
0.333333333333333, 0, 0.666666666666667, 0.666666666666667, 0,
0, 0.666666666666667, 1, 0.666666666666667, 0.333333333333333,
0.333333333333333, 0, 0, 1, 0.666666666666667, 0.666666666666667,
0, 0.333333333333333, 1, 0, 0, 0.333333333333333, 0, 0, 0.333333333333333,
0.333333333333333, 0.666666666666667, 0, 0.666666666666667, 0,
0.666666666666667, 0, 0.333333333333333, 0.666666666666667, 0.666666666666667,
0.666666666666667, NA, 0, 0.333333333333333, 0, 0, 0.666666666666667,
0.666666666666667, 0, 0.333333333333333, 0.333333333333333, 0.666666666666667,
0.333333333333333, 0.333333333333333, 0.333333333333333, 0.333333333333333,
0.333333333333333, 0, NA, 0.333333333333333, 0.333333333333333,
0.333333333333333, 0, 0, 0.333333333333333, 0, 1, 0, 0.333333333333333,
0.333333333333333, 0.333333333333333, NA, 0, 0.666666666666667,
0.333333333333333, 0, NA, 0.666666666666667, 0.333333333333333,
0.333333333333333, 0.666666666666667, 0, 0, 0.333333333333333,
0.333333333333333, 0.333333333333333, 0.333333333333333, 0.666666666666667,
0.666666666666667, 0.333333333333333, 0, 0, 0.333333333333333,
0, 0), var1 = c(-3, 6, NA, -1, -1, -1, -1, -1, -1, NA,
NA, -1, NA, -1, -1, -1, -1, NA, -1, -1, 5, -1, -1, -1, NA, -1,
-1, -1, 1, 3, 5, -1, -1, -1, -1, 2, 1, 5, -1, -1, 1, NA, -2,
NA, NA, -1, 5, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, 8, NA,
-1, -1, -1, -3, NA, 1, NA, 11, -1, -1, NA, -1, -1, -1, -1, 5,
-1, 2, 5, 4, NA, -1, -1, -1, -1, -1, -1, -1, NA, -1, -1, -1,
4, -1, 11, -1, NA, -1, -1, NA, -1, -1, NA, NA, NA, NA, 2, -1,
-1, -1, -1, -1, NA, -1, -1, -1, NA, 10, 4, -1, -1, 5, -1, -1,
-1, 4, NA, 5, -1, -1, 5, NA, 4, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 2, 3, -1, NA, 5, 2, -1, -1, -1, -1, 1, -2, -1, 0, -1, -1,
-1, 6, -1, NA, -2, 2, -1, 3, -1, -1, NA, 5, NA, -3, -1, -3, -1,
-1, -1, -1, -1, -1, 2, -1, 1, -1, -1, NA, 3, -1, -1, 4, -1, -1,
-1, 7, -3, 6, -1, NA, -1, -1, NA, -1, 11, 3, 7, NA, -1, -1, -1,
-1, 0, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, NA, -5, -1, -1,
-1, NA, 2, -1, -3, NA, -1, 0, NA, NA, 1, -1, NA, -1, -1, NA,
NA, 3, -1, -10, 2, -1, -1, -1, -1, -3), group = structure(c(2L,
2L, NA, 1L, 1L, 1L, 2L, 1L, 1L, NA, NA, 1L, NA, 1L, 1L, 1L, 1L,
NA, 1L, 1L, 3L, 2L, 1L, 1L, NA, 1L, 1L, 1L, 3L, 3L, 3L, 1L, 2L,
1L, 1L, 2L, 3L, 3L, 1L, 2L, 3L, NA, 3L, NA, NA, 1L, 3L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, NA, 1L, 1L, 2L, 2L, NA, 3L,
NA, 2L, 1L, 1L, NA, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 3L, 2L, NA, 1L,
1L, 1L, 1L, 2L, 1L, 1L, NA, 1L, 1L, 1L, 3L, 1L, 2L, 1L, NA, 1L,
1L, NA, 1L, 1L, NA, NA, NA, NA, 2L, 2L, 1L, 3L, 1L, 1L, NA, 2L,
1L, 1L, NA, 2L, 2L, 1L, 2L, 3L, 1L, 2L, 2L, 3L, NA, 2L, 1L, 1L,
3L, NA, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 3L, 1L, NA,
3L, 2L, 1L, 1L, 1L, 1L, 3L, 3L, 1L, 2L, 1L, 1L, 1L, 3L, 1L, NA,
3L, 3L, 1L, 3L, 1L, 1L, NA, 2L, NA, 2L, 2L, 3L, 1L, 1L, 1L, 1L,
1L, 3L, 2L, 2L, 3L, 3L, 1L, NA, 2L, 1L, 1L, 3L, 2L, 1L, 1L, 3L,
2L, 3L, 1L, NA, 1L, 1L, NA, 1L, 2L, 3L, 3L, NA, 1L, 1L, 1L, 2L,
2L, 3L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, NA, 2L, 3L, 1L, 2L,
NA, 3L, 1L, 2L, NA, 1L, 2L, NA, NA, 2L, 1L, NA, 1L, 1L, NA, NA,
2L, 2L, 2L, 3L, 1L, 1L, 2L, 1L, 2L), levels = c("group1",
"group2", "group3"), class = "factor"), var2 = c(0,
1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1,
1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1,
0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0,
0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0,
0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0), RY = c(1520052009,
5580012006, 1520002005, 1700082007, 8620062010, 2180102005, 1700032009,
323012001, 3206192002, 8620252017, 760032002, 2222062008, 8580062020,
3206202006, 680052015, 5580012003, 3400012000, 6040192010, 2223022006,
5910042003, 680032015, 8580032010, 3400012016, 5910012001, 680042007,
680042011, 2180102008, 5580042020, 8620262001, 8620072010, 680012015,
322092000, 680092001, 680032006, 2180022013, 6000011998, 8620072007,
5580022016, 6040192002, 3206142017, 760052005, 6040122004, 5910012005,
5910012020, 5580102010, 8580012018, 760042020, 1520092018, 2223022007,
1880022000, 3206172006, 8620252015, 2180192020, 680072003, 8580172018,
1520082017, 5910012007, 6000212011, 680032010, 6040142006, 3207102004,
3400082008, 3208062011, 323012001, 2223052011, 321012020, 6000262017,
4843092011, 3400032020, 3201092005, 3205082013, 6040002001, 1880092016,
2222042005, 1880082016, 1880012018, 1700082013, 5580022017, 3400182017,
2180102002, 329011998, 760022003, 1520002017, 760032005, 8620262013,
3400082003, 5910012000, 6040002013, 1700062006, 680052017, 5580032016,
8580012008, 6040062009, 6000202017, 4844321996, 680082002, 3201092018,
3201092008, 3400122002, 1700092001, 5580012000, 3400062002, 6000242016,
323042011, 5910052002, 1700062013, 8620252003, 6000011998, 8580152017,
760042009, 1520001995, 1700072002, 6000022010, 8580042001, 6000252016,
2221022002, 6000192015, 5580172003, 2180022020, 5919012016, 2180192018,
8620232009, 8580072018, 760032016, 5910042003, 8580011998, 5580152005,
4844322002, 680092004, 2180062018, 1520112010, 3400062018, 1700082017,
4844072005, 320022010, 2180062008, 760332015, 5910042006, 8620152007,
3400062016, 2180102018, 4841192013, 8620022010, 760022010, 320012015,
5580012016, 1880022001, 3200142010, 5910042017, 1700082004, 6000252018,
680032008, 680032003, 680012001, 4849012003, 8580102004, 3400062003,
1520002009, 323032013, 8620262011, 321011997, 680032003, 323022005,
5580012008, 2180062013, 760022007, 6040022013, 8620242004, 1880022015,
8580042004, 4842231996, 8580052017, 760022006, 1880042009, 2180122008,
2180142020, 3204182007, 1880022020, 760052010, 3400062013, 3206142005,
8580022001, 2180022006, 3206172015, 3208072011, 3207102005, 680082017,
760042003, 8620122006, 8620312020, 3206212013, 6040122008, 680042020,
4843092013, 8580012011, 323042018, 1880072005, 6000092010, 680092001,
5910052001, 8580032009, 6000192017, 8580182006, 323012016, 760032009,
3208072011, 3204132008, 5580012008, 2180052016, 760022006, 2180012013,
760032018, 5910012003, 5580112017, 322102008, 8620252015, 3400022006,
1700042002, 8580102007, 3206142013, 1700072018, 1520082005, 2180072006,
6040022018, 2223072011, 4841052004, 680062010, 3400082016, 1520082009,
8580052000, 323002003, 1880031998, 3400152004, 4849022003, 1520002020,
5910042017, 1520102007, 5580062020, 4841282007, 680012017, 1880012000,
1700062015, 323012017, 1520051995, 680032009, 1700072002, 5910022013,
680082011, 5580122007, 4843301996), country = c("Chile", "Nicaragua",
"Chile", "Colombia", "Venezuela", "Ecuador", "Colombia", "Argentina",
"Guatemala", "Venezuela", "Brazil", "El Salvador", "Uruguay",
"Guatemala", "Bolivia", "Nicaragua", "Honduras", "Peru", "El Salvador",
"Panama", "Bolivia", "Uruguay", "Honduras", "Panama", "Bolivia",
"Bolivia", "Ecuador", "Nicaragua", "Venezuela", "Venezuela",
"Bolivia", "Argentina", "Bolivia", "Bolivia", "Ecuador", "Paraguay",
"Venezuela", "Nicaragua", "Peru", "Guatemala", "Brazil", "Peru",
"Panama", "Panama", "Nicaragua", "Uruguay", "Brazil", "Chile",
"El Salvador", "Costa Rica", "Guatemala", "Venezuela", "Ecuador",
"Bolivia", "Uruguay", "Chile", "Panama", "Paraguay", "Bolivia",
"Peru", "Guatemala", "Honduras", "Guatemala", "Argentina", "El Salvador",
"Argentina", "Paraguay", "Mexico", "Honduras", "Guatemala", "Guatemala",
"Peru", "Costa Rica", "El Salvador", "Costa Rica", "Costa Rica",
"Colombia", "Nicaragua", "Honduras", "Ecuador", "Argentina",
"Brazil", "Chile", "Brazil", "Venezuela", "Honduras", "Panama",
"Peru", "Colombia", "Bolivia", "Nicaragua", "Uruguay", "Peru",
"Paraguay", "Mexico", "Bolivia", "Guatemala", "Guatemala", "Honduras",
"Colombia", "Nicaragua", "Honduras", "Paraguay", "Argentina",
"Panama", "Colombia", "Venezuela", "Paraguay", "Uruguay", "Brazil",
"Chile", "Colombia", "Paraguay", "Uruguay", "Paraguay", "El Salvador",
"Paraguay", "Nicaragua", "Ecuador", "Panama", "Ecuador", "Venezuela",
"Uruguay", "Brazil", "Panama", "Uruguay", "Nicaragua", "Mexico",
"Bolivia", "Ecuador", "Chile", "Honduras", "Colombia", "Mexico",
"Argentina", "Ecuador", "Brazil", "Panama", "Venezuela", "Honduras",
"Ecuador", "Mexico", "Venezuela", "Brazil", "Argentina", "Nicaragua",
"Costa Rica", "Guatemala", "Panama", "Colombia", "Paraguay",
"Bolivia", "Bolivia", "Bolivia", "Mexico", "Uruguay", "Honduras",
"Chile", "Argentina", "Venezuela", "Argentina", "Bolivia", "Argentina",
"Nicaragua", "Ecuador", "Brazil", "Peru", "Venezuela", "Costa Rica",
"Uruguay", "Mexico", "Uruguay", "Brazil", "Costa Rica", "Ecuador",
"Ecuador", "Guatemala", "Costa Rica", "Brazil", "Honduras", "Guatemala",
"Uruguay", "Ecuador", "Guatemala", "Guatemala", "Guatemala",
"Bolivia", "Brazil", "Venezuela", "Venezuela", "Guatemala", "Peru",
"Bolivia", "Mexico", "Uruguay", "Argentina", "Costa Rica", "Paraguay",
"Bolivia", "Panama", "Uruguay", "Paraguay", "Uruguay", "Argentina",
"Brazil", "Guatemala", "Guatemala", "Nicaragua", "Ecuador", "Brazil",
"Ecuador", "Brazil", "Panama", "Nicaragua", "Argentina", "Venezuela",
"Honduras", "Colombia", "Uruguay", "Guatemala", "Colombia", "Chile",
"Ecuador", "Peru", "El Salvador", "Mexico", "Bolivia", "Honduras",
"Chile", "Uruguay", "Argentina", "Costa Rica", "Honduras", "Mexico",
"Chile", "Panama", "Chile", "Nicaragua", "Mexico", "Bolivia",
"Costa Rica", "Colombia", "Argentina", "Chile", "Bolivia", "Colombia",
"Panama", "Bolivia", "Nicaragua", "Mexico"), year = c(2009, 2006,
2005, 2007, 2010, 2005, 2009, 2001, 2002, 2017, 2002, 2008, 2020,
2006, 2015, 2003, 2000, 2010, 2006, 2003, 2015, 2010, 2016, 2001,
2007, 2011, 2008, 2020, 2001, 2010, 2015, 2000, 2001, 2006, 2013,
1998, 2007, 2016, 2002, 2017, 2005, 2004, 2005, 2020, 2010, 2018,
2020, 2018, 2007, 2000, 2006, 2015, 2020, 2003, 2018, 2017, 2007,
2011, 2010, 2006, 2004, 2008, 2011, 2001, 2011, 2020, 2017, 2011,
2020, 2005, 2013, 2001, 2016, 2005, 2016, 2018, 2013, 2017, 2017,
2002, 1998, 2003, 2017, 2005, 2013, 2003, 2000, 2013, 2006, 2017,
2016, 2008, 2009, 2017, 1996, 2002, 2018, 2008, 2002, 2001, 2000,
2002, 2016, 2011, 2002, 2013, 2003, 1998, 2017, 2009, 1995, 2002,
2010, 2001, 2016, 2002, 2015, 2003, 2020, 2016, 2018, 2009, 2018,
2016, 2003, 1998, 2005, 2002, 2004, 2018, 2010, 2018, 2017, 2005,
2010, 2008, 2015, 2006, 2007, 2016, 2018, 2013, 2010, 2010, 2015,
2016, 2001, 2010, 2017, 2004, 2018, 2008, 2003, 2001, 2003, 2004,
2003, 2009, 2013, 2011, 1997, 2003, 2005, 2008, 2013, 2007, 2013,
2004, 2015, 2004, 1996, 2017, 2006, 2009, 2008, 2020, 2007, 2020,
2010, 2013, 2005, 2001, 2006, 2015, 2011, 2005, 2017, 2003, 2006,
2020, 2013, 2008, 2020, 2013, 2011, 2018, 2005, 2010, 2001, 2001,
2009, 2017, 2006, 2016, 2009, 2011, 2008, 2008, 2016, 2006, 2013,
2018, 2003, 2017, 2008, 2015, 2006, 2002, 2007, 2013, 2018, 2005,
2006, 2018, 2011, 2004, 2010, 2016, 2009, 2000, 2003, 1998, 2004,
2003, 2020, 2017, 2007, 2020, 2007, 2017, 2000, 2015, 2017, 1995,
2009, 2002, 2013, 2011, 2007, 1996), CY = c("2009Chile", "2006Nicaragua",
"2005Chile", "2007Colombia", "2010Venezuela", "2005Ecuador",
"2009Colombia", "2001Argentina", "2002Guatemala", "2017Venezuela",
"2002Brazil", "2008El Salvador", "2020Uruguay", "2006Guatemala",
"2015Bolivia", "2003Nicaragua", "2000Honduras", "2010Peru", "2006El Salvador",
"2003Panama", "2015Bolivia", "2010Uruguay", "2016Honduras", "2001Panama",
"2007Bolivia", "2011Bolivia", "2008Ecuador", "2020Nicaragua",
"2001Venezuela", "2010Venezuela", "2015Bolivia", "2000Argentina",
"2001Bolivia", "2006Bolivia", "2013Ecuador", "1998Paraguay",
"2007Venezuela", "2016Nicaragua", "2002Peru", "2017Guatemala",
"2005Brazil", "2004Peru", "2005Panama", "2020Panama", "2010Nicaragua",
"2018Uruguay", "2020Brazil", "2018Chile", "2007El Salvador",
"2000Costa Rica", "2006Guatemala", "2015Venezuela", "2020Ecuador",
"2003Bolivia", "2018Uruguay", "2017Chile", "2007Panama", "2011Paraguay",
"2010Bolivia", "2006Peru", "2004Guatemala", "2008Honduras", "2011Guatemala",
"2001Argentina", "2011El Salvador", "2020Argentina", "2017Paraguay",
"2011Mexico", "2020Honduras", "2005Guatemala", "2013Guatemala",
"2001Peru", "2016Costa Rica", "2005El Salvador", "2016Costa Rica",
"2018Costa Rica", "2013Colombia", "2017Nicaragua", "2017Honduras",
"2002Ecuador", "1998Argentina", "2003Brazil", "2017Chile", "2005Brazil",
"2013Venezuela", "2003Honduras", "2000Panama", "2013Peru", "2006Colombia",
"2017Bolivia", "2016Nicaragua", "2008Uruguay", "2009Peru", "2017Paraguay",
"1996Mexico", "2002Bolivia", "2018Guatemala", "2008Guatemala",
"2002Honduras", "2001Colombia", "2000Nicaragua", "2002Honduras",
"2016Paraguay", "2011Argentina", "2002Panama", "2013Colombia",
"2003Venezuela", "1998Paraguay", "2017Uruguay", "2009Brazil",
"1995Chile", "2002Colombia", "2010Paraguay", "2001Uruguay", "2016Paraguay",
"2002El Salvador", "2015Paraguay", "2003Nicaragua", "2020Ecuador",
"2016Panama", "2018Ecuador", "2009Venezuela", "2018Uruguay",
"2016Brazil", "2003Panama", "1998Uruguay", "2005Nicaragua", "2002Mexico",
"2004Bolivia", "2018Ecuador", "2010Chile", "2018Honduras", "2017Colombia",
"2005Mexico", "2010Argentina", "2008Ecuador", "2015Brazil", "2006Panama",
"2007Venezuela", "2016Honduras", "2018Ecuador", "2013Mexico",
"2010Venezuela", "2010Brazil", "2015Argentina", "2016Nicaragua",
"2001Costa Rica", "2010Guatemala", "2017Panama", "2004Colombia",
"2018Paraguay", "2008Bolivia", "2003Bolivia", "2001Bolivia",
"2003Mexico", "2004Uruguay", "2003Honduras", "2009Chile", "2013Argentina",
"2011Venezuela", "1997Argentina", "2003Bolivia", "2005Argentina",
"2008Nicaragua", "2013Ecuador", "2007Brazil", "2013Peru", "2004Venezuela",
"2015Costa Rica", "2004Uruguay", "1996Mexico", "2017Uruguay",
"2006Brazil", "2009Costa Rica", "2008Ecuador", "2020Ecuador",
"2007Guatemala", "2020Costa Rica", "2010Brazil", "2013Honduras",
"2005Guatemala", "2001Uruguay", "2006Ecuador", "2015Guatemala",
"2011Guatemala", "2005Guatemala", "2017Bolivia", "2003Brazil",
"2006Venezuela", "2020Venezuela", "2013Guatemala", "2008Peru",
"2020Bolivia", "2013Mexico", "2011Uruguay", "2018Argentina",
"2005Costa Rica", "2010Paraguay", "2001Bolivia", "2001Panama",
"2009Uruguay", "2017Paraguay", "2006Uruguay", "2016Argentina",
"2009Brazil", "2011Guatemala", "2008Guatemala", "2008Nicaragua",
"2016Ecuador", "2006Brazil", "2013Ecuador", "2018Brazil", "2003Panama",
"2017Nicaragua", "2008Argentina", "2015Venezuela", "2006Honduras",
"2002Colombia", "2007Uruguay", "2013Guatemala", "2018Colombia",
"2005Chile", "2006Ecuador", "2018Peru", "2011El Salvador", "2004Mexico",
"2010Bolivia", "2016Honduras", "2009Chile", "2000Uruguay", "2003Argentina",
"1998Costa Rica", "2004Honduras", "2003Mexico", "2020Chile",
"2017Panama", "2007Chile", "2020Nicaragua", "2007Mexico", "2017Bolivia",
"2000Costa Rica", "2015Colombia", "2017Argentina", "1995Chile",
"2009Bolivia", "2002Colombia", "2013Panama", "2011Bolivia", "2007Nicaragua",
"1996Mexico")), row.names = c(NA, -250L), class = c("tbl_df",
"tbl", "data.frame")) |>
mutate(var1 = factor(var1))
vcov_stub <- as.formula("~ CY")
fmla_works <- as.formula(paste0("DV ~ var2:(group) + group |", "RY"))
reg_works <- feols(data = df, fml = fmla_works, vcov = vcov_stub)
fmla_fails <- as.formula(paste0("DV ~ var1:(group) + group |", "RY"))
reg_fails <- feols(data = df, fml = fmla_fails, vcov = vcov_stub)
fmla_fails <- as.formula(paste0("DV ~ var1:(group) + group |", "country + year"))
reg_fails <- feols(data = df, fml = fmla_fails, vcov = vcov_stub)
fmla_fails <- as.formula(paste0("DV ~ var1:(group) + group |", "country"))
reg_fails <- feols(data = df, fml = fmla_fails, vcov = vcov_stub)
fmla_fails <- as.formula(paste0("DV ~ var1:(group) + group |", "year"))
reg_fails <- feols(data = df, fml = fmla_fails, vcov = vcov_stub)
reg_works is computed properly, with the only warning being that observations were removed due to NAs (as should happen. But when I run any of the reg_fails models, I get warnings like:
The variables 'var1-1:groupgroup1' and 'var17:groupgroup3' have been removed because of collinearity (see $collin.var)
The second is no problem, as that is simply caused by there not being sufficient variation in group3 of the group var for that level of var. However, the first should not happen, as "group1" is the reference level for group so it shouldn't be computed in the first place, let alone drop.
What I don't understand is how the first regression works, but the others do not. var2 is a dichotomous variable, between 0 and 1, where group1 always has a 0. So group1 can be used as the reference level, but cannot have its own estimate. But var1 works the same way: it is a factor variable, where all those in group = group1 have a value of -1. Why, then, does it force the calculation of a baseline (uninteracted estimate) only for it to be dropped? I want to estimate the same model essentially, just with increased variation for the other observations in group = group2 and group3. This works in reg_works, which only produces estimates for group2 and group3, along with interactions with var2.
The additional reg_fails attempts show that the change in fixed effects does not alter anything (other than the warnings that are not important).
Why is R forcing estimation of interactions for the reference level? Why does this only happen with var1 and not var2? How can I make it treat the reference level of group the same way when interacted with var1 as with var2, and only compute interactions for group = group2 or group = group3?
Note that I need var1 to remain a factor variable. It cannot be a numeric variable.
I'm guessing that deep down in the estimation routine
fixestis making use of some call tomodel.matrix. The behavior that OP is describing is the default behavior ofmodel.matrix(or standardlm).When modeling interactions, the default is that one also wants to estimate the additional effect of a secondary variable (here
var1) on the main effect. In case of afactorizedmain effect -- when there is a reference category -- that doesn't necesseraly mean that there is no (relevant) additional effect of the secondary variable on this category. That is,var1-1:groupgroup1is equivalent to a main effect of the category-1ofvar1. You can suppress the computation ofvar1-1:groupgroup1if you explicitely model the main effectvar1(which is not what OP is looking for; just an explanation of what I think is happening). See the following calls.However, OP explicitely requested that there is no interaction effect of
var1on the reference category ofgroup(i.e. the main effects ofvar1). The packagefixestprovides a mechanism to model interaction terms more flexible using the functioni()(for greater details refer to the manual fori()or the Details subsection Interactions within the manual forfeols()). So, assuming methodological adequacy, you can use the following statement to explicitely suppress effects ofvar1ongroupvaluegroup1.