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" <[email protected]>
To   <[email protected]>
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 
[email protected] 

[email protected]
> 
> 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index