Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: loop over tests

 From Nikolaos Kanellopoulos To statalist@hsphsun2.harvard.edu Subject Re: st: loop over tests Date Mon, 10 May 2010 06:54:27 +0000 (GMT)

Martin,

Thank you very much for the suggestion.

Nikos

----- Original Message ----
From: Martin Weiss <martin.weiss1@gmx.de>
To: statalist@hsphsun2.harvard.edu
Sent: Fri, May 7, 2010 5:31:44 PM
Subject: RE: st: loop over tests

<>
Quite apart from the construction of the loop, you may want to capture the results with a -postfile-. Scanning them manually would be difficult and error-prone.

HTH
Martin

-original message-
Subject: st: loop over tests
From: Nikolaos Kanellopoulos <nkkanel@yahoo.gr>
Date: 07-05-2010 16:21

Dear all,

I want to run the following tests after a regression command:
sysuse auto , clear
ta rep78, gen(t)
reg price  mpg t1 t2 t3 t4

/*First set of tests: Test each variable with the rest*/
test t1 = t2
test t1 = t3
test t1 = t4
test t2 = t3
test t2 = t4
test t3 = t4

/*Second set of tests: Test all possible combinations*/
test t1 = t2
test t1 = t2 = t3
test t1 = t2 = t3 = t4
test t2 = t3
test t2 = t3 = t4
test t3 = t4

For the first set I do something like:
forv i=1/4{
local min = `i' + 1
forv l = `min'/4 {
test t`i' = t`l'
}
}

Is there a way to do a loop for the second set as well and is there a more efficient way for my loop.
In my actual dataset the number of variables I need to test are almost 100.

Nikos

*
*  For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://www.ats.ucla.edu/stat/stata/

*
*  For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://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/