Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: using lags within -xi-


From   "Jason Yackee" <jyackee@law.usc.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: using lags within -xi-
Date   Tue, 22 Aug 2006 11:30:34 -0700

Stata 8 does not support the l. command with xtreg, though it does with xtpcse.  In stata 8 to use a lagged dv with xtreg you have to generate the lag as a separate variable, e.g. by gen lag2gdp = l2.gdp.  You can't do it on the fly.  xtreg gdp l.gdp inflation l.inflation will not work in xtreg.  On the other hand, xtpcse gdp l1.gdp inf l1.ing will work.
 
Stata 9 _does_ support the l. command with xtreg (a good reason to upgrade).  I just did it.  Don't know why it is not working for you unless your data isn't tsset and sorted correctly.
 
When generating your lagged variables, make sure you have tsset your data first, & that it is sorted by unit then year.  this may be your problem
 
JY

________________________________

From: owner-statalist@hsphsun2.harvard.edu on behalf of Scott Cunningham
Sent: Tue 8/22/2006 11:18 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: using lags within -xi-



I've a panel with 20 years.  I want to estimate a dynamic model with 
fixed effects, and thought I could just use the L.depvar operator 
within -xtreg-, but I'm not having much luck.  The -xi- manual 
("Cross-Sectional Time Series") is not all that helpful under -xtreg- 
on including lags, making me wonder if it is not within -xtreg- where 
you implement lags.  I tried generating, but that's not 
straightforward either, as I appear to be only successful at lagging 
across cross-sectional observations (-gen lm1=mir[_n-1]- will, I 
think, not lag by year, but by cross-sectional observation, and Stata 
doesn't recognize [_t-1]).  I tried using the L.vbl and L2.vbl, but 
it keeps telling me my data is not sorted, which subsequent sorting 
along various lines (sort year, sort variable year, sort year 
variable - none work).

I only have three help volumes here with me at work - Stata 8 -xi-, 
Reference A-F, and Graphics.  The program I'm running is Stata 9.2, 
but my manuals are all Stata 8.
 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


<<winmail.dat>>




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