Stuart-Maxwell-test for marginal homogeneity

Install required packages

coin

wants <- c("coin")
has   <- wants %in% rownames(installed.packages())
if(any(!has)) install.packages(wants[!has])

MH-test

categ <- factor(1:3, labels=c("lo", "med", "hi"))
drug  <- rep(categ, c(30, 50, 20))
plac  <- rep(rep(categ, length(categ)), c(14,7,9, 5,26,19, 1,7,12))
cTab  <- table(drug, plac)
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
library(coin)
mh_test(cTab, distribution=approximate(B=9999))

    Approximative Marginal-Homogeneity Test

data:  response by
     groups (drug, plac) 
     stratified by block 
chi-squared = 12.14, p-value = 0.0017

Detach (automatically) loaded packages (if possible)

try(detach(package:coin))
try(detach(package:modeltools))
try(detach(package:survival))
try(detach(package:mvtnorm))
try(detach(package:splines))
try(detach(package:stats4))

Get the article source from GitHub

R markdown - markdown - R code - all posts