bfTest {asht}R Documentation

Behrens-Fisher Test

Description

Tests for a difference in means from two normally distributed variates with possibly different variances.

Usage

bfTest(x, ...)

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

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

Arguments

x

a (non-empty) numeric vector of data values.

y

an optional (non-empty) numeric vector of data values.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

mu

a number indicating the true value of the difference in means

conf.level

confidence level of the interval.

control

a list of arguments used for determining the calculation algorithm, see bfControl

formula

a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs 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").

...

further arguments to be passed to or from methods.

Details

Fisher (1935) developed a fiducial solution to the two-sample difference in means problem with normally distributed data with different variances. That has become known as the Behrens-Fisher solution. Robinson (1976) showed through extensive simulations, that the Behrens-Fisher solution is valid (i.e., the test gives type I error rate less than the significance level, and its confidence intervals on the difference in means have coverage at least as large as the nominal confidence level).

The following are the same as with the usual t-test in t.test. alternative = "greater" is the alternative that x has a larger mean than y. Missing values are silently removed. If the input data are effectively constant an error is generated.

Value

A list with class "htest" containing the following components:

statistic

the value of the t-statistic.

parameter

R = atan(SEMx/SEMy) used in Behrens-Fisher distribution, where SEMx=std error of the mean of x, see pbf, but not used in calculation for this function

p.value

the p-value for the test.

conf.int

a confidence interval for the difference in means (mean.x-mean.y) appropriate to the specified alternative hypothesis.

estimate

the estimated means

null.value

the specified hypothesized value of the mean difference

alternative

a character string describing the alternative hypothesis.

method

a character string describing the test.

data.name

a character string giving the name(s) of the data.

References

Fisher, RA (1935). The fiducial argument in statistical inference. Annals of Eugenics. 6, 391-398.

Robinson, G (1976). Properties of Students t and of the Behrens-Fisher solution to the two means problem. The Annals of Statistics 4, 963-971 (Corr: 1982, p. 321).

See Also

The more common solution for this problem is Welch's t-test (the default in t.test). Welch's t-test does not guarantee that the type I error rate is less than the significance level, but it appears to work well in most cases.

Examples

## Classical example: Student's sleep data
## Traditional interface
with(sleep, bfTest(extra[group == 1], extra[group == 2]))
## Formula interface
bfTest(extra ~ group, data = sleep)
## Results are simular to Welch's t-test, 
## but a little more conservative
t.test(extra~group,data=sleep)

[Package asht version 1.0.1 Index]