Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: st: RE: Panel data: large number of linear time trends


From   Christopher Baum <kit.baum@bc.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   re: st: RE: Panel data: large number of linear time trends
Date   Fri, 24 Feb 2012 13:20:56 -0500

<>
I am estimating a panel data model, where the unit of observation is a
county-year.  There are roughly 3,100 counties in the United States,
and I have data for 12 years.

I wish to include linear county-time trends.  That is, I want a
separate time trend for each county.

Estimating this model by "brute force" (by interacting time with a
dummy for each county) would mean having an additional 3,100 variables
to my model.  Is there a more efficient way to estimate this model?


The Frisch-Waugh-Lovell theorem (as discussed in the Baum-Schaffer-Stillman papers describing -ivreg2- on SSC) tells you that if you want to 'partial off' the effects of a set of variables, be they time trends, seasonals, etc. in computing a regression, you may either insert the appropriate regressors, or 
perform the transformation separately, take the residuals, and use them as the new response variable. So it the case of time trends to be estimated separately for each panel unit, you may detrend the response variable separately for each county, save the residuals (optionally adding back the county-level mean) and put that detrended dep.var. into your regression. 

One difficulty here is that statsby: (or just plain by:) can run the regressions, as Nick suggests, and save the coefficients, but it cannot also compute the predicted values or residuals. The simplest solution to that, as described in ISP below, is to write a simple 'wrapper' program that will do both the regression and prediction. E.g., based loosely on -myregress- (ssc type myregress.ado):

clear all
program mydetrend, rclass byable(recall)
version 10.1
syntax varlist [if] [in], DETrend(varname) 
tempvar eps
marksample touse
regress `varlist' if `touse'
predict double `eps' if e(sample), res
replace `detrend' = `eps' if e(sample)
end

webuse grunfeld
g invest_dtr = .
by company: mydetrend invest year, det(invest_dtr)

The variable invest_dtr contains detrended invest. If you want it to have the same units as invest, compute the subsample means and add them to each subsample.

Kit

Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
                             An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
  An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index