Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: RE: loop over tests


From   Nikolaos Kanellopoulos <[email protected]>
To   [email protected]
Subject   Re: st: RE: loop over tests
Date   Mon, 10 May 2010 09:51:34 +0000 (GMT)

Nick ,

thanks for your maieutic reply. 
I have indeed found a solution based on the loop I had and utilizing the accumulate option. 

Nikos


----- Original Message ----
From: Nick Cox <[email protected]>
To: [email protected]
Sent: Sun, May 9, 2010 8:45:52 PM
Subject: st: RE: loop over tests

Be careful to penalise yourself for this "shotgun" approach. 

For once, although I can think of code, I really don't want to make it easier for you to do this. Others can speak for themselves, or more likely remain silent. 

Nick 
[email protected] 

Nikolaos Kanellopoulos


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.


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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index