behrens.test: Behrens version of the t-test for unequal variances

View source: R/behrens.test.R

behrens.testR Documentation

Behrens version of the t-test for unequal variances

Description

Behrens version of the t-test for unequal variances.

Usage

behrens.test(x, ...)

## Default S3 method:
behrens.test(
  x,
  y,
  alternative = c("two.sided", "greater", "less"),
  mu = 0,
  conf.level = 0.95,
  ...
)

## S3 method for class 'formula'
behrens.test(formula, data, subset, na.action, ...)

Arguments

x

Numeric vector of data values.

...

Further arguments to be passed to or from methods.

y

Numeric vector of data values.

alternative

Character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater", and "less".

mu

A number indicating the difference in means under the null-hypothesis.

conf.level

Confidence level of the interval, default is 0.95.

formula

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

data

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

subset

An optional vector specifying a subset of observations to be used.

na.action

A function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action").

Details

Computes Behrens version of the t-test for unequal variances based on approximate solution as in Box & Tiao, 1973, Section 2.5.3; see also Armitage, Berry, Matthews, 2002, Section 4.3.

Examples

weightWomen <- c(38.9, 61.2, 73.3, 21.8, 63.4, 64.6, 48.4, 48.8, 48.5)
weightMen <-   c(67.8, 60  , 63.4, 76,   89.4, 73.3, 67.3, 61.3)

# using the default method
behrens.test(x = weightWomen, y = weightMen)
behrens.test(x = weightWomen, y = weightMen, alternative = "less")

# using the formula interface
weight <- matrix(c(weightWomen, weightMen, rep(1, 9), rep(2, 8)), ncol = 2)
colnames(weight) <- c("measure", "sex") 
behrens.test(measure ~ sex, data = weight)

felix-hof/biostatUZH documentation built on Sept. 27, 2024, 1:48 p.m.