Regression with a large dummy-variable set (e.g., firm and year fixed effects) in Stata

I run a regression in Stata with a Compustat dataset that contains fyear and gvkey. I want to add firm and year fixed effects, so I type the following command:

regress DV IV i.fyear i.gvkey

But Stata returns the error r(103), which suggests “too many variables specified”. It turns out that the culprit is i.gvkey.

I find two work-arounds:

(1) Use both xtset and xtreg:
xtset gvkey
xtreg DV IV i.fyear, fe

(2) Use areg:
areg DV IV i.fyear, absorb(gvkey)

xtreg is the Stata command for fixed-, between-, and random-effects linear models, and areg is the Stata command for linear regression with a large dummy-variable set.

In my example, I find that both commands returns exactly same results.

This entry was posted in Stata. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *