⇦ Back

This example comes from the RDocumentation site for friedman.test(). It uses data from Hollander & Wolfe’s (1973) “Nonparametric statistical methods”, p 140ff, documenting a comparison of three methods (“round out”, “narrow angle” and “wide angle”) for rounding first base in baseball:

For each of 22 players and the three methods tested, the average time of two runs from a point on the first base line 35 ft from home plate to a point 15 ft short of second base is recorded.

Here’s the raw data:

rounding_times <- matrix(
    c(
        5.40, 5.50, 5.55,
        5.85, 5.70, 5.75,
        5.20, 5.60, 5.50,
        5.55, 5.50, 5.40,
        5.90, 5.85, 5.70,
        5.45, 5.55, 5.60,
        5.40, 5.40, 5.35,
        5.45, 5.50, 5.35,
        5.25, 5.15, 5.00,
        5.85, 5.80, 5.70,
        5.25, 5.20, 5.10,
        5.65, 5.55, 5.45,
        5.60, 5.35, 5.45,
        5.05, 5.00, 4.95,
        5.50, 5.50, 5.40,
        5.45, 5.55, 5.50,
        5.55, 5.55, 5.35,
        5.45, 5.50, 5.55,
        5.50, 5.45, 5.25,
        5.65, 5.60, 5.40,
        5.70, 5.65, 5.55,
        6.30, 6.30, 6.25
    ),
    nrow = 22,
    byrow = TRUE,
    dimnames = list(1:22, c("Round Out", "Narrow Angle", "Wide Angle"))
)
print(head(rounding_times))
##   Round Out Narrow Angle Wide Angle
## 1      5.40         5.50       5.55
## 2      5.85         5.70       5.75
## 3      5.20         5.60       5.50
## 4      5.55         5.50       5.40
## 5      5.90         5.85       5.70
## 6      5.45         5.55       5.60

Which Statistical Test Should Be Used?

  • The (alternative) hypothesis is that there is a difference in speed between the three methods
  • The variable being measured is time, which is continuous
  • The hypothesis is that the participants will record a different time if they use each of the three methods
  • Specifically, the hypothesis is that the mean time taken when using each method will be different
  • There are more than two groups (there are three)
  • We cannot assume that the data is Normally distributed, so a nonparametric test should be used
  • If one participant is a naturally fast runner then all three of their times should be lower than another participant’s. Thus the measurements are not-independent.

Using the above flowchart we see that we should use Friedman two-way ANOVA.

Performing the Friedman Test

The Friedman test is performed using the friedman.test() function:

friedman.test(rounding_times)
## 
##  Friedman rank sum test
## 
## data:  rounding_times
## Friedman chi-squared = 11.143, df = 2, p-value = 0.003805

As we can see from the output the p-value was 0.003805, which is strong evidence in favour of the alternative hypothesis (which is that the methods are not equivalent with respect to speed). The individual values that have been returned can be accessed by setting a variable equal to friedman.test() and then indexing it:

f <- friedman.test(rounding_times)

# Get the value of Friedman's chi-squared statistic
chi_squared <- f$statistic
# Get the degrees of freedom of the approximate chi-squared distribution of
# the test statistic
df <- f$parameter
# Get the p-value of the test
p <- f$p.value
# Get the character string "Friedman rank sum test"
method <- f$method
# Get a character string giving the names of the data
name <- f$data.name

# Print them all
print(chi_squared)
print(df)
print(p)
print(method)
print(name)
## Friedman chi-squared 
##             11.14286 
## df 
##  2 
## [1] 0.003805041
## [1] "Friedman rank sum test"
## [1] "rounding_times"

⇦ Back