DeclareDesign / estimatr

estimatr: Fast Estimators for Design-Based Inference
https://declaredesign.org/r/estimatr
Other
131 stars 20 forks source link

Choose baseline year? #400

Open GustavFlorinAagren opened 1 year ago

GustavFlorinAagren commented 1 year ago

When I do the following call:

reg <– lm_robust(logwealth ~ treat:as.factor(Year),
data = AJZ, fixed_effects = ~ Region + Year, clusters = Region)

it produces the following using summary(reg):

Call: lm_robust(formula = logwealth ~ treat:as.factor(Year), data = AJZ, clusters = Region, fixed_effects = ~Region + Year)

Standard error type: CR2

Coefficients: (1 not defined because the design matrix is rank deficient) Estimate Std. Error t value Pr(>|t|) CI Lower treat:as.factor(Year)2000 -0.1229535 0.11031 -1.11464 0.3157 -0.40651 treat:as.factor(Year)2001 -0.1504377 0.10413 -1.44472 0.2082 -0.41811 treat:as.factor(Year)2002 -0.1176582 0.10318 -1.14032 0.3058 -0.38289 treat:as.factor(Year)2003 -0.0696706 0.11191 -0.62257 0.5609 -0.35734 treat:as.factor(Year)2004 -0.0955070 0.11824 -0.80772 0.4559 -0.39946 treat:as.factor(Year)2005 -0.1133926 0.10802 -1.04976 0.3419 -0.39106 treat:as.factor(Year)2006 -0.1276116 0.10113 -1.26189 0.2627 -0.38757 treat:as.factor(Year)2007 -0.0996432 0.10099 -0.98664 0.3691 -0.35925 treat:as.factor(Year)2008 -0.0488581 0.11964 -0.40837 0.6999 -0.35641 treat:as.factor(Year)2009 -0.1052350 0.10961 -0.96006 0.3811 -0.38700 treat:as.factor(Year)2010 0.0009388 0.08355 0.01124 0.9915 -0.21383 treat:as.factor(Year)2011 0.0367939 0.07435 0.49491 0.6416 -0.15432 treat:as.factor(Year)2012 -0.0388336 0.05338 -0.72748 0.4996 -0.17605 treat:as.factor(Year)2013 0.0115102 0.02916 0.39476 0.7093 -0.06344 treat:as.factor(Year)2014 NA NA NA NA NA

To me it seems that lm_robust chooses for this call 2014 to be the coefficient not defined. This seems arbitrary since if I change the call a little, putting the FEs as as.factor in the function lm_robust chooses arbitrarily 2004 to be the year to not define coefficients for. I'm Interested in knowing if it's possible to choose which year to be the one not defined. In my case, I would like 2006 to be dropped so that it becomes the baseline year. Is there any way to do this?

nfultz commented 1 year ago

See also https://stackoverflow.com/q/3872070/986793

GustavFlorinAagren commented 1 year ago

Hi!

I know of the solution to use relevel. But it ends up the same way anyway:

Call: lm_robust(formula = logwealth ~ treat:relevel(as.factor(Year), ref = "2006"), data = AJZ, clusters = Region, fixed_effects = ~as.factor(Year) + as.factor(Region))

Standard error type: CR2

Coefficients: (1 not defined because the design matrix is rank deficient) Estimate Std. Error treat:relevel(as.factor(Year), ref = "2006")2006 -0.1276116 0.10113 treat:relevel(as.factor(Year), ref = "2006")2000 -0.1229535 0.11031 treat:relevel(as.factor(Year), ref = "2006")2001 -0.1504377 0.10413 treat:relevel(as.factor(Year), ref = "2006")2002 -0.1176582 0.10318 treat:relevel(as.factor(Year), ref = "2006")2003 -0.0696706 0.11191 treat:relevel(as.factor(Year), ref = "2006")2004 -0.0955070 0.11824 treat:relevel(as.factor(Year), ref = "2006")2005 -0.1133926 0.10802 treat:relevel(as.factor(Year), ref = "2006")2007 -0.0996432 0.10099 treat:relevel(as.factor(Year), ref = "2006")2008 -0.0488581 0.11964 treat:relevel(as.factor(Year), ref = "2006")2009 -0.1052350 0.10961 treat:relevel(as.factor(Year), ref = "2006")2010 0.0009388 0.08355 treat:relevel(as.factor(Year), ref = "2006")2011 0.0367939 0.07435 treat:relevel(as.factor(Year), ref = "2006")2012 -0.0388336 0.05338 treat:relevel(as.factor(Year), ref = "2006")2013 0.0115102 0.02916 treat:relevel(as.factor(Year), ref = "2006")2014 NA NA

How come this doesn't solve the problem?