# Re: st: AW: Loop over regression estimates

 From itchiftc@rumms.uni-mannheim.de To statalist@hsphsun2.harvard.edu Subject Re: st: AW: Loop over regression estimates Date Sun, 27 Sep 2009 00:40:15 +0200

```Hello Martin,

```
thanks for your help. How could I just forget local... Probably because I was thinking it's not going to work anyway...
```But it works now! Great :)
Thank you once again!

Ida

Zitat von Martin Weiss <martin.weiss1@gmx.de>:

```
```
<>

Forgot the word "local"

*************
sysuse auto, clear

reg pr weight turn
estimates store h1m4s
reg pr headroom weight turn
estimates store h1m4a
reg pr headroom weight length turn
estimates store h1m4z
reg pr headroom weight length mpg turn
estimates store h1m4t

local hyp1 "h1m4s h1m4a h1m4t h1m4z"
foreach est of local hyp1 {
estimates restore `est'
test turn=weight
local F_`est'=r(F)
local P_`est'=r(p)
}
*************

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von
itchiftc@rumms.uni-mannheim.de
Gesendet: Sonntag, 27. September 2009 00:06
An: statalist@hsphsun2.harvard.edu
Betreff: st: Loop over regression estimates

Dear all,

I have to conduct a simple Wald test (-test x1=x2=x3=x4=0-) for
several different regression specifications. I have done the
regressions and stored the estimates under a name that identifies the
hypothesis, the model and the dependent variable (e.g. h1m1a). Now I
would like to write a loop over all stored estimates, conduct the
tests and store the F-stat and the p-value in order to export them
later by means of -outreg2-. I have tried the loop, listed below, but
unfortunately Stata says that the syntax is wrong. The problem lies
probably in the foreach-command but I don't know which other loop to
take for regression estimates and whether it is possible at all.

Here is what I tried:

local hyp1 "h1m4s h1m4a h1m4t h1m4z"
foreach est of hyp1 {
estimates restore `est'
test x1=x2=x3=x4=0
local F_`est'=r(F)
local P_`est'=r(p)
}

I would appreciate any help or references where I can read how to make it.

Best regards,
Ida
*
*   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/

```
```

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