
#example 6.1
## Hollander & Wolfe (1973), 116.
## Mucociliary efficiency from the rate of removal of dust in normal
##  subjects, subjects with obstructive airway disease, and subjects
##  with asbestosis.
x <- c(2.9, 3.0, 2.5, 2.6, 3.2) # normal subjects
y <- c(3.8, 2.7, 4.0, 2.4)      # with obstructive airway disease
z <- c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosis
kruskal.test(list(x, y, z))
## Equivalently,
x <- c(x, y, z)
g <- factor(rep(1:3, c(5, 4, 5)),
            labels = c("Normal subjects",
                       "Subjects with obstructive airway disease",
                       "Subjects with asbestosis"))
kruskal.test(x, g)

#p-value
pchisq(0.7714, 2, ncp=0, lower.tail=F)


#section 6.4
#example 6.5
x1 <- c(40,35,38,43,44,41)
b1 <- c(38,40,47,44,40,42)
c1 <- c(48,40,45,43,46,44)
y1 <- c(b1,c1)
ans = wilcox.exact(y1,x1, paired = F, alternative = "greater")
W = ans$statistic + length(x1)*length(y1)
W