General Instructions

To do each example, just click the Submit button. You do not have to type in any R instructions or specify a dataset. That's already done for you.


Example 7.1 in Hollander and Wolfe.



Note: In the friedman.test function call the groups variable goes in front of the vertical bar and the blocks variable goes behind the vertical bar. We are looking for a method effect here so method goes in front of the bar.

The second analysis done by the aov function is the usual parametric procedure: two-way ANOVA. It produces P = 0.004084 for comparison with the Friedman P-value.

The first line tells R that player is to be treated as a factor, that is, as a non-numerical variable. If it were omitted, the ANOVA would be nonsense. For some reason friedman.test comes out the same if it is omitted.

We don't also have to tell R that method is a factor, because it automatically treats any non-numerical variable as a factor. If method had been designated by numerical codes, we would also need a statement like the first line for method.

If R were consistent, these two analyses would have similar syntax, but it isn't and they don't.

Warning: Do not omit the lines converting the categorical variables to R factor objects. At least don't omit them unless you are sure it won't make a difference.

More Exact Computation

The contributed package SuppDists contains a better approximation to the distribution of the Friedman test statistic under the null hypothesis. Here's how that works.

The P-value hardly changes, and in this example is so small that the better calculation makes no difference. Either way the treatment is highly statistically significant. But on different data, the better calculation might be important.