Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: residuals over years


From   Christopher F Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: residuals over years
Date   Tue, 19 Oct 2004 06:35:05 -0400

On Oct 19, 2004, at 2:33, David wrote:

for each y of local Y {
      reg  y  x1  x2  x3  if year==`y'
      predict temp, residual
      replace residual=temp if year==`y'
      drop temp
}

Two issues:

(1) it is usually a good idea to 'predict double' when computing residuals unless memory is a real issue.

(2) the 'predict' above is overwhelmingly inefficient (computationally) because it will predict over the whole sample. Use 'predict temp if e(sample), residual' to avoid this. The replace if-clause can also read if e(sample), but that will not matter, since only values computed in the predict will be copied.

Kit Baum, Boston College Economics baum@bc.edu
http://ideas.repec.org/e/pba1.html

*
* 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/




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