stratified_two_sample: Stratified two-sample permutation test for equality of means

Description Usage Arguments Details Value

View source: R/means.R

Description

Stratified two-sample permutation test for equality of means

Usage

1
stratified_two_sample(group, response, stratum, stat = "mean", reps = 1000)

Arguments

group

Vector of group memberships or treatment conditions

response

Vector of measured outcomes, same length as group

stratum

Vector of stratum assignments, same length as group

stat

The test statistic. Default is 'mean'. See details for other options.

reps

Number of replications to approximate distribution (default 1000)

Details

  1. If stat == 'mean', the test statistic is (mean(x) - mean(y)) (equivalently, sum(x), since those are monotonically related), omitting NaNs, which therefore can be used to code non-responders

  2. If stat == 't', the test statistic is the two-sample t-statistic– but the p-value is still estimated by the randomization, approximating the permutation distribution. The t-statistic is computed using t.test(...,var.equal=TRUE)

  3. If stat == 'mean_within_strata', the test statistic is the difference in means within each stratum, added across strata.

  4. If stat is a function (a callable object), the test statistic is that function. The function should take a permutation of the pooled data and compute the test function from it.

Value

A vector of length 'reps' containing the permutation distribution


statlab/permuter documentation built on May 30, 2019, 9:45 a.m.