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 on April 23, and its replacement, is already up and running.

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

Re: st: Equivalent to kruskal-wallis in clustered data

From   "Roger B. Newson" <>
Subject   Re: st: Equivalent to kruskal-wallis in clustered data
Date   Thu, 08 Nov 2012 12:00:10 +0000

Yes, there is a clustered version of the Kruskal-Wallis test. It can be done using the -somersd- package (downloadable from SSC) with -xi:- and -testparm-.

For instance, in the -auto- data, we might test independence of price and repair record, assuming that we are sampling car firms from a population of car firms, instead of sampling car models from a population of car models. We set up the data by typing:

sysuse auto, clear
gene firm=word(make,1)
tab firm, m

This creates and tabulates a new variable -firm-, indicating the firm that makes each car model. We then do the analysis by typing:

xi, noomit: somersd price i.rep78, transf(z) tdist

which creates variables _Irep78_1 to _Irep78_5, indicating membership of each of the 5 repair record groups, and calculates a Somers' D of each of these indicators with respect to -price-, with confidence limits and a P-value. These Somers' D parameters measure the association of each repair record group (compared to all other repair record groups) with the car's price in dollars.

To do the test, we then type:

testparm _I*

which tests the hypothesis that all 5 of these Somers' D parameters are zero, which implies that no repair group tends to be more or less expensive than the rest (the hypothesis usually tested using a Kruskall-Wallis test). We see that the P-value is 0.5618, so the null hypothesis has not been decisively refuted.

I hope this helps. Let me know if you have any further queries.

Best wishes


Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Web page:
Departmental Web page:

Opinions expressed are those of the author, not of the institution.

On 08/11/2012 10:11, alfonsa leiva wrote:
Dear fellows

Basically, GPs were randomized to 3 groups, in the bivariate analysis of effectiveness dependent variable are continuos and independet variable are groups 1,2 or 3 . There is any test equivalent to kruskall-wallis implemented in stata to test the study hypothesis adjusted for the lack of independency of the patients(clustered data by GPs)?

Thanks in advance

Alfonso Leiva
*   For searches and help try:

*   For searches and help try:

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