friedman.test
Friedman Rank Sum Test

Description

Performs a Friedman rank sum test with unreplicated blocked data.

Usage

friedman.test(y, ...)
## Default S3 method:
friedman.test(y, groups, blocks, ...)
## S3 method for class 'formula':
friedman.test(formula, data, subset, na.action, ...)

Arguments

y a numeric vector or numeric matrix that specifies the observations.

If y is a numeric matrix, the row indices specify the block membership and the column indices specify the group or treatment for each corresponding element of y and the arguments groups and blocks are ignored.

Missing values NAs are allowed, but all data for each block in which at least one element of y is a missing value (NA) is ignored. However, infinite values (Infs) are not removed because they are rankable.

groups a factor object that specifies the group (treatment) for each corresponding element of y. If groups is not a factor object, it will be coerced to one. length(groups) must equal length(y).

There must be exactly one element of y that corresponds to each combination of the levels of groups and blocks.

This argument is ignored if y is a numeric matrix.

Missing values (NAs) and infinite values (Infs) are not allowed.

blocks a factor object that specifies the block membership for each corresponding element of y. If blocks is not a factor object, it will be coerced to one. length(blocks) must equal length(y).

There must be exactly one element of y that corresponds to each combination of the levels of groups and blocks.

This argument is ignored if y is a numeric matrix.

Missing values (NAs) and infinite values (Infs) are not allowed.

formula a formula or terms that describe the model. In general, formulas follow the pattern, a ~ b | c, where a specifies the data values, b specifies the groups, and c specifies the blocks.
data a data frame or matrix that contains the objects named in formula. By default, this argument reads in values from parent.frame() and you do not need to call this argument explicitly. However, if parent.frame() contains a matrix, you must use the data argument.
subset a numeric vector that specifies a subset from the data frame (data) to use in formula.
na.action a character string that specifies how missing values (NAs) are handled. By default, an error is returned.
... further arguments to be passed to or from methods.
Value
returns a list of class htest, containing the following components:
statistic Friedman chi-square statistic along with the names attribute Friedman chi-squared.
parameter degrees of freedom of the asymptotic chi-square distribution associated with statistic along with the names attribute df.
p.value the asymptotic p-value for the test.
method a character string that returns the name of the method used, the value is Friedman rank sum test.
data.name a character string (vector of length 1) that contains the actual names of the input arguments y, groups, and blocks. If y is a numeric matrix, groups and blocks are ignored.
Null hypothesis
In the context of a two-way layout with factors groups and blocks, a typical null hypothesis is that the true location parameter for y, net of the blocks effect, is the same in each of the groups. The alternative hypothesis is that it is different in at least one of the groups. For alternative models see Hollander and Wolfe (1973).
Test assumptions
The Friedman test is appropriate for data arising from an unreplicated complete block design. That is, one in which exactly one observation was collected from each experimental unit, or block, under each treatment. The elements of y are assumed to consist of a groups effect, plus a blocks effect, plus independent and identically distributed residual errors. The interaction between groups and blocks is assumed to be zero.
You should interpret the returned p.value carefully because it is only a large-sample approximation whose validity increases with the number of blocks.
References
Hollander, M. and Wolfe, D. A. (1973). Nonparametric Statistical Methods. New York: John Wiley.
Lehmann, E. L. (1975). Nonparametrics: Statistical Methods Based on Ranks. Oakland, Calif.: Holden-Day.
See Also
wilcox.test, kruskal.test, aov, rank.
Examples
treatments <- factor(rep(c("Trt1", "Trt2", "Trt3"), each=4))
people <- factor(rep(c("Subject1", "Subject2", "Subject3", "Subject4"), 3))
y <- c(0.73,0.76,0.46,0.85,0.48,0.78,0.87,0.22,0.51,0.03,0.39,0.44)
friedman.test(y, treatments, people) 

# Now suppose the data is in the form of a matrix, rows are people and # columns are treatments. # Generate 'ymat' and the factor objects: ymat <- matrix(c(0.73,0.76,0.46,0.85,0.48,0.78,0.87,0.22,0.51, 0.03,0.39,0.44), ncol=3) bl <- factor(as.vector(row(ymat))) gr <- factor(as.vector(col(ymat))) friedman.test(ymat, gr, bl) # same answer as above

Package stats version 6.0.0-69
Package Index