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

RE: st: Residuals from sequence of regressions


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Residuals from sequence of regressions
Date   Mon, 18 Oct 2004 18:45:08 +0100

Matches some earlier postings in spirit. 
Note typo "for each" for "foreach". 

Nick 
n.j.cox@durham.ac.uk 

DBernstein@lecg.com
> 
> I'm new to replying to messages, so I hope I post this correctly.
> Anyway, here is a solution to the residual question that should work:
> If anyone has a more efficient solution, I would be 
> interested in seeing
> it.
> 
> 
> levels year, local(Y)
> 
> gen residual=.
> 
> 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
> }
> 

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