Statalist


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

st: AW: Loop over regression estimates


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Loop over regression estimates
Date   Sun, 27 Sep 2009 00:09:47 +0200

<> 

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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index