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

* For searches and help try:

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