st: Running simple autocorrelation regressions using -forval-

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

st: Running simple autocorrelation regressions using -forval-

Clive Nicholas
Stata 9.2, Windows XP

I'm having trouble executing this -forval- code:

webuse nlswork
reg ln_wage age race grade if year==68
predict r1, r
whitetst, fitted
forval i=69(1)88 {
        reg ln_wage age race grade if year==`i'
        predict r`i', r
        reg r`i' r`i_[n-1]'
        whitetst, fitted
}

The problem, of course, is with -reg r`i' r`i_[n-1]'-, which chokes
with the error code:

r ambiguous abbreviation
r(111);

Even after checking -h forval-, I can't find a satisfactory way of
getting Stata to automate the second residual term, which should be
the one estimated for the year before the first one in each
-regress-ion.

All solutions gratefully received.

--
Clive Nicholas

[Please DO NOT mail me personally here, but at
<[hidden email]>. 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/
Reply | Threaded
Open this post in threaded view
|

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

Martin Weiss-5
Line for the server...

What is that -fitted- option to -whitetst-?  I have

. which whitetst
c:\ado\plus\w\whitetst.ado
*! whitetst 1.2.0 CFB/NJC 11 Oct 1999 rev for _rmcoll  (STB-55: sg137)

and Stata says it does not know this option.

Anyway, why do you not use the lag opertors in - help tsvarlist- for your
-reg-?

HTH
Martin


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Clive Nicholas
Sent: Tuesday, December 09, 2008 9:00 AM
To: [hidden email]
Subject: st: Running simple autocorrelation regressions using -forval-

Stata 9.2, Windows XP

I'm having trouble executing this -forval- code:

webuse nlswork
reg ln_wage age race grade if year==68
predict r1, r
whitetst, fitted
forval i=69(1)88 {
        reg ln_wage age race grade if year==`i'
        predict r`i', r
        reg r`i' r`i_[n-1]'
        whitetst, fitted
}

The problem, of course, is with -reg r`i' r`i_[n-1]'-, which chokes
with the error code:

r ambiguous abbreviation
r(111);

Even after checking -h forval-, I can't find a satisfactory way of
getting Stata to automate the second residual term, which should be
the one estimated for the year before the first one in each
-regress-ion.

All solutions gratefully received.

--
Clive Nicholas

[Please DO NOT mail me personally here, but at
<[hidden email]>. 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/

*
*   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/
Reply | Threaded
Open this post in threaded view
|

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

Richard Williams
At 03:35 AM 12/9/2008, Martin Weiss wrote:
>Line for the server...
>
>What is that -fitted- option to -whitetst-?  I have
>
>. which whitetst
>c:\ado\plus\w\whitetst.ado
>*! whitetst 1.2.0 CFB/NJC 11 Oct 1999 rev for _rmcoll  (STB-55: sg137)
>
>and Stata says it does not know this option.

You have an old version:

. which whitetst
c:\ado\plus\w\whitetst.ado
*! whitetst 1.2.3 CFB/NJC  17 Feb 2002 add fitted option for special
form of test

According to the help,

"Alternatively, a special form of the test, described by Wooldridge
(2000, pp. 259-260), may be employed by specifying the fitted option.
In this form, the predicted values from the original regression and
their squares are used in place of the individual regressors, their
squares, and
their cross-products. This form of the test imposes constraints on
the auxiliary regression, but may be a very attractive alternative if
the original regressor list is lengthy."



-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  [hidden email]
WWW:    http://www.nd.edu/~rwilliam

*
*   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/
Reply | Threaded
Open this post in threaded view
|

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

Martin Weiss-5

Line for the server...

I installed from the uppermost link after -findit whitetst- which was not a
good choice... When I -adoupdate whitetst, all- it does not update either...

HTH
Martin


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Richard Williams
Sent: Tuesday, December 09, 2008 10:20 AM
To: [hidden email]; [hidden email]
Subject: Re: st: RE: Running simple autocorrelation regressions using
-forval-

At 03:35 AM 12/9/2008, Martin Weiss wrote:
>Line for the server...
>
>What is that -fitted- option to -whitetst-?  I have
>
>. which whitetst
>c:\ado\plus\w\whitetst.ado
>*! whitetst 1.2.0 CFB/NJC 11 Oct 1999 rev for _rmcoll  (STB-55: sg137)
>
>and Stata says it does not know this option.

You have an old version:

. which whitetst
c:\ado\plus\w\whitetst.ado
*! whitetst 1.2.3 CFB/NJC  17 Feb 2002 add fitted option for special
form of test

According to the help,

"Alternatively, a special form of the test, described by Wooldridge
(2000, pp. 259-260), may be employed by specifying the fitted option.
In this form, the predicted values from the original regression and
their squares are used in place of the individual regressors, their
squares, and
their cross-products. This form of the test imposes constraints on
the auxiliary regression, but may be a very attractive alternative if
the original regressor list is lengthy."



-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  [hidden email]
WWW:    http://www.nd.edu/~rwilliam

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

*
*   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/
Reply | Threaded
Open this post in threaded view
|

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

Richard Ochmann
In reply to this post by Clive Nicholas
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
}
***********
best,
rich




"Clive Nicholas" <[hidden email]>
Gesendet von: [hidden email]
09.12.2008 09:01
Bitte antworten an
[hidden email]


An
[hidden email]
Kopie

Thema
st: Running simple autocorrelation regressions using -forval-






Stata 9.2, Windows XP

I'm having trouble executing this -forval- code:

webuse nlswork
reg ln_wage age race grade if year==68
predict r1, r
whitetst, fitted
forval i=69(1)88 {
        reg ln_wage age race grade if year==`i'
        predict r`i', r
        reg r`i' r`i_[n-1]'
        whitetst, fitted
}

The problem, of course, is with -reg r`i' r`i_[n-1]'-, which chokes
with the error code:

r ambiguous abbreviation
r(111);

Even after checking -h forval-, I can't find a satisfactory way of
getting Stata to automate the second residual term, which should be
the one estimated for the year before the first one in each
-regress-ion.

All solutions gratefully received.

--
Clive Nicholas

[Please DO NOT mail me personally here, but at
<[hidden email]>. 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/


*
*   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/
Reply | Threaded
Open this post in threaded view
|

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

Richard Williams
In reply to this post by Martin Weiss-5
At 04:29 AM 12/9/2008, Martin Weiss wrote:

>Line for the server...
>
>I installed from the uppermost link after -findit whitetst- which was not a
>good choice... When I -adoupdate whitetst, all- it does not update either...
>
>HTH
>Martin

A common trap.  STB and Stata Journal programs are often less current
than the SSC version.  adoupdate won't fix that; it only looks for
newer versions posted on the same site as where you got the
original.  You have to install the SSC version (or the version from
whatever site has the most current version).


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  [hidden email]
WWW:    http://www.nd.edu/~rwilliam

*
*   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/
Reply | Threaded
Open this post in threaded view
|

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

Martin Weiss-5

Line for the server...

Should -findit- be modified then to display the more recent links at the
top? STB is by definition old, so it should relegate those hits to the
bottom.

HTH
Martin


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Richard Williams
Sent: Tuesday, December 09, 2008 10:58 AM
To: [hidden email]; [hidden email]
Subject: RE: st: RE: Running simple autocorrelation regressions using
-forval-

At 04:29 AM 12/9/2008, Martin Weiss wrote:

>Line for the server...
>
>I installed from the uppermost link after -findit whitetst- which was not a
>good choice... When I -adoupdate whitetst, all- it does not update
either...
>
>HTH
>Martin

A common trap.  STB and Stata Journal programs are often less current
than the SSC version.  adoupdate won't fix that; it only looks for
newer versions posted on the same site as where you got the
original.  You have to install the SSC version (or the version from
whatever site has the most current version).


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  [hidden email]
WWW:    http://www.nd.edu/~rwilliam

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

*
*   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/
Reply | Threaded
Open this post in threaded view
|

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

Joao Ricardo F. Lima
In reply to this post by Clive Nicholas
Dear Clive,

I think that you can just do this:

 webuse nlswork
 reg ln_wage age race grade if year==68
 predict r1, r
 whitetst, fitted
 forval i=69(1)88 {
        reg ln_wage age race grade if year==`i'
        predict r`i', r
        reg r`i' L.r`i'                                     /*change
r`i_[n-1]' to L.r`i'*/
        whitetst, fitted
 }

The result is the same of Rich Ochmann, but I'm not using a new local macro.

HTH,

Joao Lima
2008/12/9 Clive Nicholas <[hidden email]>:

> Stata 9.2, Windows XP
>
> I'm having trouble executing this -forval- code:
>
> webuse nlswork
> reg ln_wage age race grade if year==68
> predict r1, r
> whitetst, fitted
> forval i=69(1)88 {
>        reg ln_wage age race grade if year==`i'
>        predict r`i', r
>        reg r`i' r`i_[n-1]'
>        whitetst, fitted
> }
>
> The problem, of course, is with -reg r`i' r`i_[n-1]'-, which chokes
> with the error code:
>
> r ambiguous abbreviation
> r(111);
>
> Even after checking -h forval-, I can't find a satisfactory way of
> getting Stata to automate the second residual term, which should be
> the one estimated for the year before the first one in each
> -regress-ion.
>
> All solutions gratefully received.
>
> --
> Clive Nicholas
>
> [Please DO NOT mail me personally here, but at
> <[hidden email]>. 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/
>



--
----------------------------------------
Joao Ricardo Lima, D.Sc.
Professor
UFPB-CCA-DCFS
Fone: +553138923914
Skype: joao_ricardo_lima
----------------------------------------
*
*   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/
Reply | Threaded
Open this post in threaded view
|

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

Joao Ricardo F. Lima
Clive

sorry, the result is not the same. In the Rich code the regress is,
for example, r73 against r72 and I'm doing r73 against r73 lagged.

Joao Lima

2008/12/9 Joao Ricardo F. Lima <[hidden email]>:

> Dear Clive,
>
> I think that you can just do this:
>
>  webuse nlswork
>  reg ln_wage age race grade if year==68
>  predict r1, r
>  whitetst, fitted
>  forval i=69(1)88 {
>        reg ln_wage age race grade if year==`i'
>        predict r`i', r
>        reg r`i' L.r`i'                                     /*change
> r`i_[n-1]' to L.r`i'*/
>        whitetst, fitted
>  }
>
> The result is the same of Rich Ochmann, but I'm not using a new local macro.
>
> HTH,
>
> Joao Lima
> 2008/12/9 Clive Nicholas <[hidden email]>:
>> Stata 9.2, Windows XP
>>
>> I'm having trouble executing this -forval- code:
>>
>> webuse nlswork
>> reg ln_wage age race grade if year==68
>> predict r1, r
>> whitetst, fitted
>> forval i=69(1)88 {
>>        reg ln_wage age race grade if year==`i'
>>        predict r`i', r
>>        reg r`i' r`i_[n-1]'
>>        whitetst, fitted
>> }
>>
>> The problem, of course, is with -reg r`i' r`i_[n-1]'-, which chokes
>> with the error code:
>>
>> r ambiguous abbreviation
>> r(111);
>>
>> Even after checking -h forval-, I can't find a satisfactory way of
>> getting Stata to automate the second residual term, which should be
>> the one estimated for the year before the first one in each
>> -regress-ion.
>>
>> All solutions gratefully received.
>>
>> --
>> Clive Nicholas
>>
>> [Please DO NOT mail me personally here, but at
>> <[hidden email]>. 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/
>>
>
>
>
> --
> ----------------------------------------
> Joao Ricardo Lima, D.Sc.
> Professor
> UFPB-CCA-DCFS
> Fone: +553138923914
> Skype: joao_ricardo_lima
> ----------------------------------------
>



--
----------------------------------------
Joao Ricardo Lima, D.Sc.
Professor
UFPB-CCA-DCFS
Fone: +553138923914
Skype: joao_ricardo_lima
----------------------------------------
*
*   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/
Reply | Threaded
Open this post in threaded view
|

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

Clive Nicholas
In reply to this post by Richard Ochmann
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
<[hidden email]>. 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/