
Last chance! 50% off unlimited learning
Sale ends in
A function to facilitate 2 group permutation tests for a categorical outcome variable
compareProportion(formula, data = NULL, ...)
a formula
a data frame in which x
is evaluated if x
is a
formula.
other arguments
the difference in proportions between the second and first group
# NOT RUN {
if (require(mosaicData)) {
data(HELPrct)
# calculate the observed difference
mean(homeless=="housed" ~ sex, data=HELPrct)
obs <- diffprop(homeless=="housed" ~ sex, data=HELPrct); obs
# calculate the permutation distribution
nulldist <- do(100) * diffprop(homeless=="housed" ~ shuffle(sex), data=HELPrct)
histogram(~ diffprop, groups=(diffprop>= obs), nulldist,
xlab="difference in proportions")
}
# }
Run the code above in your browser using DataLab