LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2008, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 29 Apr 2008 09:10:00 -0400
Reply-To:     wcw2 <wcw2@CDC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         wcw2 <wcw2@CDC.GOV>
Subject:      Re: Availability of Friedman Rank Sum Test

Here's some documentation I found yesterday, as I'm considering doing the same thing:

********************************************************************;

data friede; input block IV DV @@; cards; 1 1 50 1 2 58 1 3 54 2 1 32 2 2 37 2 3 25 3 1 60 3 2 70 3 3 63 4 1 58 4 2 60 4 3 55 5 1 41 5 2 66 5 3 59 6 1 36 6 2 40 6 3 28 7 1 26 7 2 25 7 3 20 8 1 49 8 2 60 8 3 50 9 1 72 9 2 73 9 3 75 10 1 49 10 2 54 10 3 42 11 1 52 11 2 57 11 3 47 12 1 36 12 2 42 12 3 29 13 1 37 13 2 34 13 3 31 14 1 58 14 2 50 14 3 56 15 1 39 15 2 48 15 3 44 16 1 25 16 2 29 16 3 18 17 1 51 17 2 63 17 3 68

proc rank out=ranks; var DV; by block; ranks ranks; * proc print; * Remove asterisk in line above if you want to see output of proc rank.;

title 'Nonparametric Analysis With SAS: Friedman ANOVA'; run; proc freq; tables block*IV*ranks / noprint cmh; title2 'Statistic 2 is the Friedman Chi-Square'; run;

proc glm; class block IV; model ranks=block IV; lsmeans IV / pdiff; title2 'GLM approach with multiple comparisons built in'; run; proc sort data=friede; by IV; proc means mean median std skewness kurtosis n; var DV; by IV; run;

/********************************************************************** In response to a query on SAS-L regarding how to do a Friedman test on SAS [summarized by Stephen P. Baker (sbaker@umassmed.bitnet)], most of the respondents suggested applying ranks within the blocks then performing a randomized block anova on the these ranks. This is, however, not exactly equivalent to the traditional Friedman test. Conover and Davenport proposed this in 1980 and in a paper in The American Statistician. Conover and Iman in 1981 proposed parametric methods on ranks as a cure-all to lots of problems. In that paper they pointed out that the F from this is a monotonic function of the Friedman statistic and they suggested that the F from the ranks within blocks was a better approximation to the Friedman than the usual chi-squared approximation.

Above is an example of how to do a Friedman analysis on SAS. The data are in the file FRIEDMAN DATA. In this data file each subject or block has three data lines, one for each level of the IV. The data are not already ranked within blocks, so the first step is to convert DV into such ranks, which is what is done by PROC RANK. PROC FREQ is then used to obtain the Friedman chi-square. The table produced has three statistics, the second of which is the Friedman Chi-Square with p-value (or actually a Cochran-Mantel- Haenszel statistic which is identical in this special case).

Siegel warns that when the table is small, this approximation is not good and provides exact tables for up to a 3 x 9 table and up to a 4 x 4 table.

Since the F approach is a better approximation, for large tables the GLM approach on the ranks might be the best option. Wim Lemmens provided the SAS code from a SUGI paper referenced in the SAS/STAT guide for doing Friedman in GLM and an associated multiple comparisons procedure which might be controversial in itself (e.g. a Bonferroni adjustment - one might want to do matched pairs-signed ranks tests and then Bonferroni adjust them.

Our sample program includes the GLM code to do the F-approach analysis with multiple comparisons via pdiff on lsmeans.

We could do the pairwise comparisons the way we did earlier following the Kruskal-Wallis. That is, create three data sets (one with IV < 3, one with IV > 1, and one with IV NE 2) and do a Wilcoxon Signed Ranks tests on each.


Back to: Top of message | Previous page | Main SAS-L page