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: Loop to compare several variables within different timepoints


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Loop to compare several variables within different timepoints
Date   Sun, 2 Feb 2014 10:52:37 +0000

Statistically, this sounds dubious and unsound: the tests are not
independent and the shotgun approach raises questions about your
interpretation of the resulting P-values.

Focusing on the Stata question, which is of some wider interest:

If your variables were just a1, a2, a3, ..., c1, c2, c3 you could go

foreach v in a b c {
      signrank `v'1 = `v'2
      signrank `v'3 = `v'2
}

so this just raises the question of how to extend "a b c" to whatever
stubs you have. Your description of variable names is too vague
("about 25 variables") to imply exact code, but this shows one trick:

unab stubs : *1
local stubs : subinstr local stubs "1" "", all

That would reduce (e.g.)

a1 b1 c1 d1 e1 f1 g1 h1 i1 j1

to

a b c d e f g h i j

after which the code would be

foreach v of local stubs {
      signrank `v'1 = `v'2
      signrank `v'3 = `v'2
}

Nick
[email protected]


On 2 February 2014 10:38, Nikolaos Pandis <[email protected]> wrote:
> I have about 25 variables for  which I recorded outcomes at 3 times
> points (t1, t2, t3)
> I  would like to construct a loop where I can automate testing using
> the "signrank" test
>
> I would like to do the following:
>
> signrank a1=a2
> signrank b1=b2
> signrank c1=c2
> .....
> signrank a3=a2
> signrank b3=b2
> signrank c3=c2
> ..............
>
> a,b,c are the variables and 1,2,3 refer to the timepoints
>
> I am only interested in 25*2=50 comparisons and not to compare
> different letter variables between them. Only within the same
> variables to compare between timepoints.
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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