# NOT RUN {
## Graubard and Korn (1987, Tab. 3)
## One-sided approximative (Monte Carlo) Cochran-Armitage test
## Note: midpoint scores (p < 0.05)
midpoints <- c(0, 0.5, 1.5, 4.0, 7.0)
chisq_test(malformation ~ consumption, data = malformations,
distribution = approximate(nresample = 1000),
alternative = "greater",
scores = list(consumption = midpoints))
## One-sided approximative (Monte Carlo) Cochran-Armitage test
## Note: midrank scores (p > 0.05)
midranks <- c(8557.5, 24375.5, 32013.0, 32473.0, 32555.5)
chisq_test(malformation ~ consumption, data = malformations,
distribution = approximate(nresample = 1000),
alternative = "greater",
scores = list(consumption = midranks))
## One-sided approximative (Monte Carlo) Cochran-Armitage test
## Note: equally spaced scores (p > 0.05)
chisq_test(malformation ~ consumption, data = malformations,
distribution = approximate(nresample = 1000),
alternative = "greater")
# }
# NOT RUN {
## One-sided approximative (Monte Carlo) score-independent test
## Winell and Lindbaeck (2018)
(it <- independence_test(malformation ~ consumption, data = malformations,
distribution = approximate(nresample = 1000,
parallel = "snow",
ncpus = 8),
alternative = "greater",
xtrafo = function(data)
trafo(data, ordered_trafo = zheng_trafo)))
## Extract the "best" set of scores
ss <- statistic(it, type = "standardized")
idx <- which(ss == max(ss), arr.ind = TRUE)
ss[idx[1], idx[2], drop = FALSE]
# }
Run the code above in your browser using DataLab