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.