0
$\begingroup$

Here's a simple example of a regression of y on x including time and id fixed-effects and both a linear and a quadratic time trend. If my t starts at 1, these 3 different regressions get the same coefficient.

#d;
set seed 123;
clear;
set obs 30;
gen id = floor((_n+4)/5);
bysort id: gen t = _n;
gen x = rnormal();
gen y = rnormal()/100 + 0.3*x;
gen tsq = t^2;

/* Creates dummies for each id and each t and trends */
gen D_id1 = id == 1;
gen D_id2 = id == 2;
gen D_id3 = id == 3;
gen D_id4 = id == 4;
gen D_id5 = id == 5;
gen D_id6 = id == 6;
gen D_t1 = t == 1;
gen D_t2 = t == 2;
gen D_t3 = t == 3;
gen D_t4 = t == 4;
gen D_t5 = t == 5;

gen TT_id1 = t*(id == 1);
gen TT_id2 = t*(id == 2);
gen TT_id3 = t*(id == 3);
gen TT_id4 = t*(id == 4);
gen TT_id5 = t*(id == 5);
gen TT_id6 = t*(id == 6);

gen TT2_id1 = t^2*(id == 1);
gen TT2_id2 = t^2*(id == 2);
gen TT2_id3 = t^2*(id == 3);
gen TT2_id4 = t^2*(id == 4);
gen TT2_id5 = t^2*(id == 5);
gen TT2_id6 = t^2*(id == 6);

/* No collinearity */
reg y x i.t i.id id#c.t id#c.tsq;
reg y x D_* TT_* TT2_*;
reghdfe y x id#c.t id#c.tsq, a(t id);

Here, the coefficient for x is .2960102 for the 3 specifications. If I make "t" larger, however, the first 2 regressions report different coefficients for x and exclude a different number of variables due to collinearity, while the third (reghdfe) one stays the same:

/* Full collinearity */
replace t = t+200;
replace tsq = t^2;
replace TT_id1 = t*(id == 1);
replace TT_id2 = t*(id == 2);
replace TT_id3 = t*(id == 3);
replace TT_id4 = t*(id == 4);
replace TT_id5 = t*(id == 5);
replace TT_id6 = t*(id == 6);

replace TT2_id1 = t^2*(id == 1);
replace TT2_id2 = t^2*(id == 2);
replace TT2_id3 = t^2*(id == 3);
replace TT2_id4 = t^2*(id == 4);
replace TT2_id5 = t^2*(id == 5);
replace TT2_id6 = t^2*(id == 6);

reg y x i.t i.id id#c.t id#c.tsq;
reg y x D_* TT_* TT2_*;
reghdfe y x id#c.t id#c.tsq, a(t id);

With outputs:

Output of 1st regression

Output of second regression

Output of third regression

I'd like to understand exactly what makes the 2 first regressions different from the third one, and only once I increase the level of t. Could someone help?

$\endgroup$

1 Answer 1

2
$\begingroup$

reghdfe is different because, by default, it tries to deal with collinearity. I don't have Stata, but a little Googling found pages about this. It should be in the documentation for the program.

The other two change because they omit variables and they omit variables because of collinearity, so the real question is why collinearity between $t$ and $t^2$ goes up when you increase $t$ by 2000. From what I can tell from your Stata code, the original $t$ went from 1 to 5 while the new $t$ went from 2001 to 2006, but those aren't critical.

It is known that there will be collinearity between a variable and its square and that this increases when the variable is far from 0. It is often recommended to center variables before doing the regression, especially if there are quadratic terms with this variable.

With only two variables involved, correlation makes a reasonable (and simple) stand in for collinearity. Here is some simple R code to show what is going on. It doesn't exactly match your case, which I am not sure how to code, but you could do this in Stata with your actual variables. Anything after a # is a comment

set.seed(1234)

x <- rnorm(1000, 0, 10) # Mean of 0
x2 <- x^2

cor(x, x2) #0.0391

xbig <- x+100  #Add a lot
xbig2 <- xbig^2
cor(xbig, xbig2) #0.997
$\endgroup$
4
  • $\begingroup$ Re documentation: Stata docs generally are excellent and widely available online. See scorreia.com/help/reghdfe.html. $\endgroup$
    – whuber
    Commented May 2 at 17:03
  • $\begingroup$ Thank you for you answer! I'd like to focus on 2 points: 1. The case here is of high correlation between regressors, but not perfect collinearity. I'd like to understand what is the rule used by Stata to decide to drop a regressor. I couldn't find this in the documentation. Is it a threshold based on a variance inflation factor? If this is the case, shouldn't the exact same variables be dropped in the first 2 cases (or at least the same number of variables)? $\endgroup$
    – why
    Commented May 2 at 19:50
  • $\begingroup$ 2. For reghdfe, the help file discusses the identification of collinear fixed effects for degree of freedom correction, but for the inclusion of covariates, this is a different thing, right? Given that the estimate for reghdfe stays the same, I'd assume that they're not dropping the variable even when the other 2 commands would based on some threshold, right? $\endgroup$
    – why
    Commented May 2 at 19:51
  • $\begingroup$ I suggest asking those questions on a Stata list. $\endgroup$
    – Peter Flom
    Commented May 2 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.