### Serum Iron Determination Using Hyland Control Sera
### Hollander & Wolfe (1999), page 147
sid <- data.frame(
serum = c(111, 107, 100, 99, 102, 106, 109, 108, 104, 99,
101, 96, 97, 102, 107, 113, 116, 113, 110, 98,
107, 108, 106, 98, 105, 103, 110, 105, 104,
100, 96, 108, 103, 104, 114, 114, 113, 108, 106, 99),
method = factor(gl(2, 20), labels = c("Ramsay", "Jung-Parekh")))
### Ansari-Bradley test, asymptotical p-value
ansari_test(serum ~ method, data = sid)
### exact p-value
ansari_test(serum ~ method, data = sid, distribution = "exact")
### Platelet Counts of Newborn Infants
### Hollander & Wolfe (1999), Table 5.4, page 171
platalet_counts <- data.frame(
counts = c(120, 124, 215, 90, 67, 95, 190, 180, 135, 399,
12, 20, 112, 32, 60, 40),
treatment = factor(c(rep("Prednisone", 10), rep("Control", 6))))
### Lepage test, Hollander & Wolfe (1999), page 172
lt <- independence_test(counts ~ treatment, data = platalet_counts,
ytrafo = function(data) trafo(data, numeric_trafo = function(x)
cbind(rank(x), ansari_trafo(x))),
teststat = "quad", distribution = approximate(B = 9999))
lt
### where did the rejection come from? Use maximum statistic
### instead of a quadratic form
ltmax <- independence_test(counts ~ treatment, data = platalet_counts,
ytrafo = function(data) trafo(data, numeric_trafo = function(x)
matrix(c(rank(x), ansari_trafo(x)), ncol = 2,
dimnames = list(1:length(x), c("Location", "Scale")))),
teststat = "max")
### points to a difference in location
pvalue(ltmax, method = "single-step")
### Funny: We could have used a simple Bonferroni procedure
### since the correlation between the Wilcoxon and Ansari-Bradley
### test statistics is zero
covariance(ltmax)
Run the code above in your browser using DataLab