perm.t.test: Permutation t-test

View source: R/stat.R

perm.t.testR Documentation

Permutation t-test

Description

Performs paired and two-sample t-tests based on Monte Carlo permutation.

Usage

perm.t.test(x, ...)

## Default S3 method:
perm.t.test(
  x,
  y = NULL,
  alternative = c("two.sided", "less", "greater"),
  paired = FALSE,
  var.equal = FALSE,
  conf.level = 0.95,
  midp = TRUE,
  B = 10000L,
  ...
)

## S3 method for class 'formula'
perm.t.test(formula, data, ...)

Arguments

x, y

vectors of numeric data

...

additional arguments passed to or from methods

alternative

a character string specifying the alternative hypothesis, one of "two.sided" (default), "greater", or "less"

paired

logical; if TRUE, x and y are assumed to be paired (NAs will remove data in pairs); if FALSE, x and y are assumed to be independent samples (NAs are removed from each sample independently)

var.equal

logical; if TRUE, two-sample variances are treated equally; otherwise, variances are estimated separately for both samples (default)

conf.level

confidence level in (0, 1) for the p-value

midp

logical; if TRUE (default), the mid p-value is used, i.e., half the conditional probability of the observed statistic plus the conditional probability of more extreme values

B

an integer specifying the number of permutations

formula

a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs a factor-like variable with two levels giving the corresponding groups

data

an optional matrix or data frame (or similar: see model.frame) containing the variables in formula; by default the variables are taken from environment(formula)

See Also

t.test

perm.t.test from the Deducer package

independence_test and symmetry_test from the coin package

paired.perm.test and perm.test from the broman package

Examples

set.seed(1)
x <- rnorm(10, 0, 0.5)
y <- rnorm(10, 0.5, 1)
dat <- data.frame(value = c(x, y), group = rep(1:2, each = 10))

## two-sample data
t.test(x, y)

## equivalent ways to call perm.t.test for two-sample data
perm.t.test(x, y)
perm.t.test(value ~ group, dat)

## paired data
t.test(x - y)
t.test(x, y, paired = TRUE)

## equivalent ways to call perm.t.test for paired data
perm.t.test(x, y, paired = TRUE)
perm.t.test(value ~ group, dat, paired = TRUE)
perm.t.test(x - y)


raredd/rawr documentation built on April 29, 2024, 10:29 a.m.