+ Reply to Thread
Results 1 to 12 of 12

Thread: Kruskal Wallis and Mood's median

  1. #1
    Points: 4,315, Level: 41
    Level completed: 83%, Points required for next Level: 35

    Posts
    156
    Thanks
    87
    Thanked 1 Time in 1 Post

    Kruskal Wallis and Mood's median




    Would appreciate some perspective on the following:

    Is the Mood's median test now rarely used?

    I am comparing right-skewed distributions (3 groups; 350 obs. each). The Kruskal-Wallis test only seems to say that there is a difference among the three but does not specifiy where the difference lies. For writing my paper, is it a good idea to do the Kruskal Wallis test first and follow it up with a Mood's median table that will show the frequencies above and below the overall median so that a sense of where the difference lies can be had? Thanks.

  2. #2
    TS Contributor
    Points: 22,157, Level: 92
    Level completed: 81%, Points required for next Level: 193
    gianmarco's Avatar
    Location
    Italy
    Posts
    1,071
    Thanks
    161
    Thanked 212 Times in 156 Posts

    Re: Kruskal Wallis and Mood's median

    Hi!
    Any stat pack routinely provides a post-hoc test to pinpoint where the significant difference is. Some software performs a pair-wise Mann-Whitney U test between samples.
    I think that you could find many earlier thread on this topic here in the Forum.

    Further, I believe that those approaches supersede Mood's median test.

    Hope this helps,
    regards
    Gm
    Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read -Groucho Marx-

  3. The Following User Says Thank You to gianmarco For This Useful Post:

    StatsClue (11-05-2012)

  4. #3
    Points: 4,315, Level: 41
    Level completed: 83%, Points required for next Level: 35

    Posts
    156
    Thanks
    87
    Thanked 1 Time in 1 Post

    Re: Kruskal Wallis and Mood's median

    Thanks a lot. I don't think SAS does. Couldn't find a post-hoc test for Kruskal-Wallis, like there exists for ANOVA (/tukey). Read up some and the suggestion seemed to be to compare each pair at a time to know where the difference lay (would of course be very difficult if there were a large number of groups). Also, that multiple-comparisons had to be accounted for using bonferroni technique that I think would tell you what signficance level to use to decide if the pairwise comparisons were signficantly different. No idea how to go about the bonferroni techique.

    Thanks again for your help.

  5. #4
    TS Contributor
    Points: 22,157, Level: 92
    Level completed: 81%, Points required for next Level: 193
    gianmarco's Avatar
    Location
    Italy
    Posts
    1,071
    Thanks
    161
    Thanked 212 Times in 156 Posts

    Re: Kruskal Wallis and Mood's median

    You could try:
    -SigmaPlot which perform Dunn test as posthoc test
    -Minitab which has a macro for KW + posthoc test
    -look at this http://www.unistat.com/guide/nonpara...-one-way-anova
    -Past, freeware, which perform (as far as I recall) KW and pairwise MW as posthoc

    Regards
    Gm
    Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read -Groucho Marx-

  6. #5
    TS Contributor
    Points: 22,157, Level: 92
    Level completed: 81%, Points required for next Level: 193
    gianmarco's Avatar
    Location
    Italy
    Posts
    1,071
    Thanks
    161
    Thanked 212 Times in 156 Posts

    Re: Kruskal Wallis and Mood's median

    p.s.

    I guess that R can easily handle the test, but I have never used it to date.
    Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read -Groucho Marx-

  7. The Following User Says Thank You to gianmarco For This Useful Post:

    StatsClue (11-14-2012)

  8. #6
    Test of Gnomality
    Points: 14,783, Level: 78
    Level completed: 84%, Points required for next Level: 67
    hlsmith's Avatar
    Posts
    2,784
    Thanks
    173
    Thanked 462 Times in 449 Posts

    Re: Kruskal Wallis and Mood's median

    Can think of two options:

    You can multiply all of the p-values from the pairwise comparisons by the number of pairwise tests to get the bonferroni corrected p-values.

    or use the following code


    Code: 
    ODS OUTPUT WilcoxonScores=wlx(drop=variable);
    ODS EXCLUDE wilcoxonScores;
    
    PROC NPAR1WAY data=full wilcoxon;
    CLASS year; VAR q1;
    TITLE1 'Nonparametric Analysis: Kruskall Wallis Test';
    run;
    
    PROC PRINT DATA=wlx NOObs ;
    run;
    
    * macro var k == number of groups;
    
    DATA _null_ ; SET wlx nobs=nobs; CALL SYMPUT("k",LEFT(nobs)); run;
    
    %put &k.;
    
    
    PROC TRANSPOSE DATA =wlx OUT=cnts(drop=_name_ _label_) prefix=_n; var n;
    ID class; run;
    PROC TRANSPOSE DATA =wlx OUT=mns(drop=_name_ _label_) prefix=_mn; var
    meanscore; ID class; run;
    
    proc print data=cnts; RUN;
    proc print data=mns; RUN;
    
    %LET alpha=.05; * familywise pvalue ;
    
    /*Below, I just substituted Z for the number that made the critical value 
      equal to the absolute difference, then looked that number up on a normal
      distribution table. This number provides the unadjusted p-value that you 
      compare with the Bonferroni alpha level of significance. */
    
    /*Next you can multiply the unadjusted p-value by k, to determine the Bonferrroni
      adjusted p-value for the wilcoxon multitest*/
    DATA results; SET cnts; SET mns; DROP nn _n1-_n&k. _mn1-_mn&k.;
    LENGTH reject $2; RETAIN reject ' ';
    LABEL compare='Critical Value' abs_diff='Absolute Difference in Mean
    Ranks';
    c= ((&k.*(&k.-1))/2); * number of pairwise tests;
    z = PROBIT( (1- ((&alpha./2)/ c) ) ); * multiplier ;
    nn=SUM(of _n1-_n&k.); * total number of observations ;
    ARRAY nc{&k.} _n1 - _n&k.;
    ARRAY mn{&k.} _mn1 - _mn&k.;
    DO i = 1 to (&k.-1);
    DO j = (i+1) TO &k.;
    sc1 = mn{i}; sc2 = mn{j};
    ABS_diff = abs(sc1 - sc2);
    compare = z * SQRT( nn*(nn+1)/12 * ((1/nc{i}) + (1/nc{j})));
    IF abs_diff > compare then reject='**'; * the ** marker is to denote
    any significant differences ;
    OUTPUT results;
    reject=' '; * reset marker to missing ;
    END;
    END;
    RUN;
    
    proc print data=results NOobs label;
    var i j sc1 sc2 ABS_diff compare reject z;
    FORMAT abs_diff 6.3 compare 6.2;
    run;

  9. The Following User Says Thank You to hlsmith For This Useful Post:

    StatsClue (11-14-2012)

  10. #7
    Points: 2,626, Level: 31
    Level completed: 18%, Points required for next Level: 124

    Location
    Dallas, TX
    Posts
    311
    Thanks
    12
    Thanked 94 Times in 93 Posts

    Re: Kruskal Wallis and Mood's median

    You can also use %DUNN macro available online. It applies Bonferroni correction to the non-parametric tests.

  11. The Following User Says Thank You to jrai For This Useful Post:

    StatsClue (11-14-2012)

  12. #8
    Test of Gnomality
    Points: 14,783, Level: 78
    Level completed: 84%, Points required for next Level: 67
    hlsmith's Avatar
    Posts
    2,784
    Thanks
    173
    Thanked 462 Times in 449 Posts

    Re: Kruskal Wallis and Mood's median

    If you are interested in this MACRO like I was, it is available at the following URL along with 2 other familywise correction MACROS:

    %DUNN MACRO available under June 2004, Simultaneous Nonparametric Inference in a One-Way Layout Using the SAS System (251 Kb zip file includes code) - Paul Juneau, Pfizer at http://www.misug.org/presentations.html

  13. The Following User Says Thank You to hlsmith For This Useful Post:

    StatsClue (11-14-2012)

  14. #9
    Points: 4,315, Level: 41
    Level completed: 83%, Points required for next Level: 35

    Posts
    156
    Thanks
    87
    Thanked 1 Time in 1 Post

    Re: Kruskal Wallis and Mood's median

    Hello, still trying to figure this out. One additional question: Can I add a fourth group here with only about a 100 observations for the comparison? i.e. the kruskal wallis will be done on 4 groups with n1=350, n2=350, n3=350, n4=100. Will the results be valid or do the number of obs. need to be about the same? THANKS A BUNCH.

  15. #10
    TS Contributor
    Points: 22,157, Level: 92
    Level completed: 81%, Points required for next Level: 193
    gianmarco's Avatar
    Location
    Italy
    Posts
    1,071
    Thanks
    161
    Thanked 212 Times in 156 Posts

    Re: Kruskal Wallis and Mood's median

    KW can be performed on samples of different size. The same applies for Dunn's posthoc test.

    Gm
    Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read -Groucho Marx-

  16. The Following User Says Thank You to gianmarco For This Useful Post:

    StatsClue (12-02-2012)

  17. #11
    Points: 4,315, Level: 41
    Level completed: 83%, Points required for next Level: 35

    Posts
    156
    Thanks
    87
    Thanked 1 Time in 1 Post

    Re: Kruskal Wallis and Mood's median

    Thank you gianmarco. I can't understand the marco above or the DUNN marco at all (I'm not even sure what macro means). My really dumb question is what to substitute where in the code above (pasted below). I only substituted the dataset name, class and variable name (starting 'statsclue..' here). The initial part seemed to run fine but the latter part was botched. I'm not sure how to find out the p-value of interest.

    Code: 
    ODS OUTPUT WilcoxonScores=wlx(drop=variable);
    ODS EXCLUDE wilcoxonScores;
    
    PROC NPAR1WAY data=STATSCLUE wilcoxon;
    CLASS STATSCLUECLASS; VAR STATSCLUEVARIABLE;
    TITLE1 'Nonparametric Analysis: Kruskall Wallis Test';
    run;
    
    PROC PRINT DATA=wlx NOObs ;
    run;
    
    * macro var k == number of groups;
    
    DATA _null_ ; SET wlx nobs=nobs; CALL SYMPUT("k",LEFT(nobs)); run; /*Should I substitute 4 for k here?*/
    
    %put &k.;
    
    
    PROC TRANSPOSE DATA =wlx OUT=cnts(drop=_name_ _label_) prefix=_n; var n;
    ID class; run;
    PROC TRANSPOSE DATA =wlx OUT=mns(drop=_name_ _label_) prefix=_mn; var
    meanscore; ID class; run;
    
    proc print data=cnts; RUN;
    proc print data=mns; RUN;
    
    %LET alpha=.05; * familywise pvalue ;
    
    /*Below, I just substituted Z for the number that made the critical value 
      equal to the absolute difference, then looked that number up on a normal
      distribution table. This number provides the unadjusted p-value that you 
      compare with the Bonferroni alpha level of significance. */
    
    /*Next you can multiply the unadjusted p-value by k, to determine the Bonferrroni
      adjusted p-value for the wilcoxon multitest*/
    DATA results; SET cnts; SET mns; DROP nn _n1-_n&k. _mn1-_mn&k.;
    LENGTH reject $2; RETAIN reject ' ';
    LABEL compare='Critical Value' abs_diff='Absolute Difference in Mean
    Ranks';
    c= ((&k.*(&k.-1))/2); * number of pairwise tests;
    z = PROBIT( (1- ((&alpha./2)/ c) ) ); * multiplier ;
    nn=SUM(of _n1-_n&k.); * total number of observations ;
    ARRAY nc{&k.} _n1 - _n&k.;
    ARRAY mn{&k.} _mn1 - _mn&k.;
    DO i = 1 to (&k.-1);
    DO j = (i+1) TO &k.;
    sc1 = mn{i}; sc2 = mn{j};
    ABS_diff = abs(sc1 - sc2);
    compare = z * SQRT( nn*(nn+1)/12 * ((1/nc{i}) + (1/nc{j})));
    IF abs_diff > compare then reject='**'; * the ** marker is to denote
    any significant differences ;
    OUTPUT results;
    reject=' '; * reset marker to missing ;
    END;
    
    END;
    RUN;
    
    proc print data=results NOobs label;
    var i j sc1 sc2 ABS_diff compare reject z;
    FORMAT abs_diff 6.3 compare 6.2;
    run;
    PS: I realize the question's dumb. Will try to comprehend this more and refine my question. Any help though would be appreciated.

  18. #12
    TS Contributor
    Points: 22,157, Level: 92
    Level completed: 81%, Points required for next Level: 193
    gianmarco's Avatar
    Location
    Italy
    Posts
    1,071
    Thanks
    161
    Thanked 212 Times in 156 Posts

    Re: Kruskal Wallis and Mood's median


    Hi!
    I am not so familiar with that macro. For what program is it for?

    Have you tried R, or some other program?

    Gm
    Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read -Groucho Marx-

+ Reply to Thread

           




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats