friedman.test(y, groups, blocks)
NA
s are allowed, but all data
for each block in which at least one element of
y
is
NA
will be removed.
Inf
s are allowed, and are not removed as they are
rankable.
y
, giving the group (treatment) for
each corresponding element of
y
.
NA
s or
Inf
s are not allowed.
If
groups
is not a factor or category object, it will be coerced to one.
y
, giving the block membership for
each corresponding element of
y
.
NA
s and
Inf
s are not allowed.
If
blocks
is not a factor or category object, it will be coerced to one.
y
corresponding to each combination of the
levels of
groups
and
blocks
.
"htest"
, containing the following components:
names
attribute
"Friedman chi-square"
. See section DETAILS for a definition.
statistic
. Component
parameters
has
names
attribute
"df"
.
"two.sided"
, to reflect that the implicit alternative hypothesis is
two-sided.
y
,
groups
and
blocks
.
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
. See Hollander and Wolfe (1973)
for alternate models.
The Friedman test is appropriate for data arising from an unreplicated
complete block design: 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.
The returned
p.value
should be interpreted carefully. It is only a
large-sample approximation whose validity increases with the number of blocks.
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.
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