Time Trend Variable in Balanced Panel Data, Stata
Solution 1
Your variable t
is just
gen t = year - 2004
and can be obtained in one line as above. Your variable t
has one small advantage over year
: if you regress a variable on t
the intercept refers to values in 2003, which is a gain on referring to values in year
0, which is way outside the range of the data.
Solution 2
In panel data analysis we call that a time effect. If you include only dummy variables for individual districts then they are called individual effects (in your case district effects). So, including either individual effects or time effect in the panel data is called one way fixed effects whereas including both is called two way fixed effects. In Stata you do the following:
use http://dss.princeton.edu/training/Panel101.dta
reg y x1 i.year # for time effect
reg y x1 i.country # for country effect (in your case district effect)
reg y x1 i.year i.country #two way fixed effect
For details see tutorial from UCLA.
Admin
Updated on June 28, 2022Comments
-
Admin almost 2 years
I have some balanced panel data and want to include trend variable into my regression. However, I have 60 districts in 7 year time period and I am not sure how to include trend variable. Year variable is repetitive as expected and for 2005-2011. I am thinking about the following;
gen t = . replace t = 1 if year==2005 replace t = 2 if year==2006
up to year 2011 and it gives me
t
variable from 1 to 7, for 180 different panels in the data.My question: is it OK to include trend variable as I described above or should I directly throw
year
variable into regression?