Bookmark and Share

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


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

Re: st: wilcoxons rank sum in data set with three groups


From   Eric Booth <eric.a.booth@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: wilcoxons rank sum in data set with three groups
Date   Tue, 27 Mar 2012 15:32:42 -0500

<>
There's no need to use preserve/restore and to drop if group==3. Instead, just use an [if] condition to limit your test to the groups of interest.  E.g., 

ranksum var1 if group==1 | group==2, by(group)
ranksum var1 if group==1 | group==3, by(group)

or

ranksum var1 if inlist(group, 1,2), by(group)
ranksum var1 if inlist(group, 1,3), by(group)


- Eric


__
Eric A. Booth
Public Policy Research Institute 
Texas A&M University
ebooth@ppri.tamu.edu
+979.845.6754

On Mar 27, 2012, at 1:30 PM, Lars Folkestad wrote:

> Dear List
> 
> I have a data set of 10 variables, continuous and 1 grouping variable.
> The grouping variable groups the data into three groups. I want to:
> 
> 1. Test if there is a difference between group 1 and 2
> 2. Test if there is a difference between group 1 and 3
> 3. Its not necessary or interesting for me if there is a difference
> between group 2 and 3.
> 
> I've done the following
> 
> . preserve
> . drop if group == 3
> . ranksum var1, by(group)
> . restore
> 
> Is there a smarter way to do this?
> 
> lars
> 
> 
> *
> *   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   |   Site index