Learn R Programming

mosaic (version 0.4-1)

compareMean: Compare means between 2 groups

Description

A function to facilitate 2 group permutation tests for a continuous outcome variable

Usage

compareMean(formula, data = NULL, ...)

Arguments

formula
a formula
data
a data frame in which x is evaluated if x is a formula.
...
other arguments

Value

  • the difference in means between the second and first group

See Also

do, compareProportion and shuffle

Examples

Run this code
data(HELPrct)
# calculate the observed difference
mean(age ~ sex, data=HELPrct)
obs <- compareMean(age ~ sex, data=HELPrct); obs
# calculate the permutation distribution
nulldist <- do(100) * compareMean(age ~ shuffle(sex),
  data=HELPrct)
xhistogram(~ result, groups=(result >= obs), nulldist,
  xlab="difference in means")

Run the code above in your browser using DataLab