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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: kruskal-wallis test |

Date |
Sun, 6 Nov 2005 17:15:47 -0000 |

In addition to Kit's suggestions, note that the sum of ranks and the mean rank are nothing exotic, and so are also obtainable directly: sysuse auto, clear egen rank = rank(mpg) if rep78 < . bysort rep78 : egen ranksum = sum(rank) by rep78 : egen rankmean = mean(rank) tabdisp rep78 if rep78 < . , c(ranksum rankmean) format(%5.1f) ---------------------------------- Repair | Record | 1978 | ranksum rankmean ----------+----------------------- 1 | 72.5 36.3 2 | 220.5 27.6 3 | 905.0 30.2 4 | 688.5 38.3 5 | 528.5 48.0 ---------------------------------- . kwallis mpg, by(rep78) Test: Equality of populations (Kruskal-Wallis test) +------------------------+ | rep78 | Obs | Rank Sum | |-------+-----+----------| | 1 | 2 | 72.50 | | 2 | 8 | 220.50 | | 3 | 30 | 905.00 | | 4 | 18 | 688.50 | | 5 | 11 | 528.50 | +------------------------+ Nick n.j.cox@durham.ac.uk Kit Baum > Herve S. says > > I run the Kruskal - Wallis tests of differences between groups. (In > reality, I use a variation -kwallis2- [donwloadable from ssc] which > provides the rank mean as well as the rank sum (-kwallis- only > provides the ranksum). > > kwallis2 index2, by(sodas3cl) > (snip) > > This code was written by another Herve, Herve Caci, back in 1999 for > Stata 5.0. Back then there was not the simple means of returning > items in a return list (one could return macros in S_1, S_2, > etc. and > it does return a few--presumably not the ones you need). > > Make a copy of kwallis2.ado (kwallis3.ado?), change the version > number to something more recent (e.g. version 8.2), change the > program define line to read "program define kwallis3, rclass" > and see > if the routine still runs and generates the same results. If so, add > return statements for each item you would like to use after the > routine runs. E.g. `Mean'`[`i'] (which is the i'th observation of a > tempvar named `Mean') is the rank mean for the i-th group. Put it in > a scalar and return it, e.g. > > return scalar mean1 = `Mean'[1] > etc. > > These items will then show up in your return list. * * 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/

- Prev by Date:
**RE: st: problem with do file stopping prematurely** - Next by Date:
**Re: st: RE: kruskal-wallis test [now -foreach, replace andappend]** - Previous by thread:
**st: kruskal-wallis test** - Next by thread:
**Re: st: RE: kruskal-wallis test [now -foreach, replace andappend]** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |