c("coin")
wants <- wants %in% rownames(installed.packages())
has <-if(any(!has)) install.packages(wants[!has])
mcnemar.test()
set.seed(123)
20
N <- rbinom(N, size=1, prob=0.6)
pre <- rbinom(N, size=1, prob=0.4)
post <- factor(pre, labels=c("no", "yes"))
preFac <- factor(post, labels=c("no", "yes"))
postFac <- table(preFac, postFac)
cTab <-addmargins(cTab)
postFac
preFac no yes Sum
no 3 5 8
yes 6 6 12
Sum 9 11 20
mcnemar.test(cTab, correct=FALSE)
McNemar's Chi-squared test
data: cTab
McNemar's chi-squared = 0.0909, df = 1, p-value = 0.763
symmetry_test()
from package coin
library(coin)
symmetry_test(cTab, teststat="quad", distribution=approximate(B=9999))
Approximative General Independence Test
data: response by
groups (postFac, preFac)
stratified by block
chi-squared = 0.0909, p-value = 1
try(detach(package:coin))
try(detach(package:survival))
try(detach(package:splines))
R markdown - markdown - R code - all posts