kruskal.test(y, groups)
NA
s are allowed, but
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 and
Inf
s are not allowed.
If
groups
is not a factor or category object, it will be coerced to one.
"htest"
, containing the following components:
names
attribute
"Kruskal-Wallis 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
and
groups
.
In the context of a one-way layout with factor
groups
,
a typical null hypothesis is that the true location parameter for
y
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 elements of
y
are assumed to consist of a
groups
effect plus
independent and identically distributed residual errors.
The returned
p.value
should be interpreted carefully. It is only a
large-sample approximation whose validity increases with the smallest of
the group sizes.
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.
# Data from Hollander and Wolfe (1973), p. 116 holl.y <- c(2.9,3.0,2.5,2.6,3.2,3.8,2.7,4.0,2.4,2.8,3.4,3.7,2.2,2.0) holl.grps <- factor(c(1,1,1,1,1,2,2,2,2,3,3,3,3,3), labels=c("Normal Subjects","Obstr. Airway Disease","Asbestosis")) kruskal.test(holl.y, holl.grps) # Now suppose the data is in the form of a table already, # with groups in columns; note this implies that group # sizes are the same. tab.data <- matrix(c(.38,.58,.15,.72,.09,.66,.52,.02,.59,.94, .24,.94,.08,.97,.47,.92,.59,.77), ncol=3) tab.data # Generate 'y' and 'groups': y2 <- as.vector(tab.data) gr <- factor(as.vector(col(tab.data))) # Groups are columns kruskal.test(y2, gr)