c("coin")
wants <- wants %in% rownames(installed.packages())
has <-if(any(!has)) install.packages(wants[!has])
mcnemar.test()
factor(1:3, labels=c("lo", "med", "hi"))
categ <- rep(categ, c(30, 50, 20))
drug <- rep(rep(categ, length(categ)), c(14,7,9, 5,26,19, 1,7,12))
plac <- table(drug, plac)
cTab <-addmargins(cTab)
plac
drug lo med hi Sum
lo 14 7 9 30
med 5 26 19 50
hi 1 7 12 20
Sum 20 40 40 100
mcnemar.test()
automatically runs the Bowker test for tables with more than 2 rows/columns
mcnemar.test(cTab)
McNemar's Chi-squared test
data: cTab
McNemar's chi-squared = 12.2718, df = 3, p-value = 0.006508
symmetry_test()
from package coin
library(coin)
symmetry_test(cTab, teststat="quad", distribution=approximate(B=9999))
Approximative General Independence Test
data: response by
groups (drug, plac)
stratified by block
chi-squared = 12.1387, p-value = 0.0017
try(detach(package:coin))
try(detach(package:survival))
try(detach(package:splines))
R markdown - markdown - R code - all posts