Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Running simple autocorrelation regressions using -forval-


From   "Clive Nicholas" <[email protected]>
To   [email protected]
Subject   Re: st: Running simple autocorrelation regressions using -forval-
Date   Tue, 9 Dec 2008 23:33:06 +0000

Richard Ochmann replied:

> not perfectly clear to me if this is what you want, but the following code
> runs for me until the year 1974 where there are no observations:
>
> ***********
> webuse nlswork
> reg ln_wage age race grade if year==68
> predict r68, r
> whitetst, fitted
> forval i=69(1)88 {
> local j = `i'-1
>        reg ln_wage age race grade if year==`i'
>        predict r`i', r
>        reg r`i' r`j'
>        whitetst, fitted
> }
> ***********

This code worked perfectly for _all_ of my data, so thanks very much.
I should have said in my original post that -whitetst- is, of course,
a user-written routine available from SSC. Indeed, my use of it should
appear _before_ -reg r`i' r`j'- and not after. I really should learn
more about locals and globals...

-- 
Clive Nicholas

[Please DO NOT mail me personally here, but at
<[email protected]>. Please respond to contributions I make in
a list thread here. Thanks!]

"My colleagues in the social sciences talk a great deal about
methodology. I prefer to call it style." -- Freeman J. Dyson.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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