Learn R Programming

PMCMRplus (version 1.9.3)

friedmanTest: Friedman Rank Sum Test

Description

Performs a Friedman rank sum test. The null hypothesis H\(_0: \theta_i = \theta_j~~(i \ne j)\) is tested against the alternative H\(_{\mathrm{A}}: \theta_i \ne \theta_j\), with at least one inequality beeing strict.

Usage

friedmanTest(y, ...)

# S3 method for default friedmanTest(y, groups, blocks, dist = c("Chisquare", "FDist"), ...)

Arguments

y

a numeric vector of data values, or a list of numeric data vectors.

groups

a vector or factor object giving the group for the corresponding elements of "x". Ignored with a warning if "x" is a list.

blocks

a vector or factor object giving the block for the corresponding elements of "x". Ignored with a warning if "x" is a list.

dist

the test distribution. Defaults to Chisquare.

further arguments to be passed to or from methods.

Value

A list with class "htest" containing the following components:

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

statistic

the estimated quantile of the test statistic.

p.value

the p-value for the test.

parameter

the parameters of the test statistic, if any.

alternative

a character string describing the alternative hypothesis.

estimates

the estimates, if any.

null.value

the estimate under the null hypothesis, if any.

Details

The function has implemented Friedman's test as well as the extension of Conover anf Iman (1981). Friedman's test statistic is assymptotically chi-squared distributed. Consequently, the default test distribution is dist = "Chisquare".

If dist = "FDist" is selected, than the approach of Conover and Imam (1981) is performed. The Friedman Test using the \(F\)-distribution leads to the same results as doing an two-way Analysis of Variance without interaction on rank transformed data.

References

Conover, W.J., Iman, R.L. (1981) Rank Transformations as a Bridge Between Parametric and Nonparametric Statistics. Am Stat 35, 124--129.

Sachs, L. (1997) Angewandte Statistik. Berlin: Springer.

See Also

friedman.test

Examples

Run this code
# NOT RUN {
## Hollander & Wolfe (1973), p. 140ff.
## Comparison of three methods ("round out", "narrow angle", and
##  "wide angle") for rounding first base.  For each of 18 players
##  and the three method, the average time of two runs from a point on
##  the first base line 35ft from home plate to a point 15ft short of
##  second base is recorded.
RoundingTimes <-
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")))

## Chisquare distribution
friedmanTest(RoundingTimes)

## check with friedman.test from R stats
friedman.test(RoundingTimes)

## F-distribution
friedmanTest(RoundingTimes, dist = "FDist")

## Check with One-way repeated measure ANOVA
rmat <- RoundingTimes
for (i in 1:length(RoundingTimes[,1])) rmat[i,] <- rank(rmat[i,])
dataf <- data.frame(
    y = y <- as.vector(rmat),
    g = g <- factor(c(col(RoundingTimes))),
    b = b <- factor(c(row(RoundingTimes))))
summary(aov(y ~ g + Error(b), data = dataf))

# }

Run the code above in your browser using DataLab