Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: cycling paired t test (and signed rank sum test)


From   Diego Bellavia <messadua@yahoo.it>
To   STATAlist <statalist@hsphsun2.harvard.edu>
Subject   st: cycling paired t test (and signed rank sum test)
Date   Sun, 21 Oct 2007 01:06:39 +0000 (GMT)

Dear Statalisters, 

I have many (~ 500) variables to test in a paired design (I would like to perform both a paired t-test and a signed rank sum test).
To avoid typing all the variables I would like to define a double loop to perform the test for all the variables. 
Since all the variables, after the reshaping in wide format of the dataset are in the format a1 b1 c1... and a2 b2 c2, basing on STATA 
documentation I tried to implement arrays, and I ended up with something like 


#delimit ; 

local array1 "a1 b1 c1";
local array2 "a2 b2 c2";

local i = 1 ;

local n : word count `array1' ;

while `i' <= `n'  {;

 local var1 : word ‘i' of ‘array1';
 local var2 : word ‘i' of ‘array2';

 ttest `var1' = `var2';
 
local i = `i' + 1;

 };

#delimit cr 


but when i run it I get an "invalid syntax" error...I cannot understand why. 

Last question: to perform a paired t-test or signed rank sum test in STATA, I am forced to 
reshape the dataset in wide format or there is some way to accomplish paired tests with the 
dataset in long format ? 

Thank you in advance for any suggestion 

Diego


      ___________________________________ 
Scopri la community di Yahoo! Mail: trucchi, novità, consigli... e la tua opinione! http://it.groups.yahoo.com/group/ymail/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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