Learn R Programming

rrcov (version 1.7-2)

T2.test: Robust Hotelling T2 test

Description

Performs one and two sample Hotelling T2 tests as well as robust one-sample Hotelling T2 test

Usage

T2.test(x, ...)

# S3 method for default T2.test(x, y = NULL, mu = 0, conf.level = 0.95, method=c("c", "mcd"), ...)

# S3 method for formula T2.test(formula, data, subset, na.action, ...)

Value

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

statistic

the value of the T2-statistic.

parameter

the degrees of freedom for the T2-statistic.

p.value

the p-value for the test.

conf.int

a confidence interval for the mean vector appropriate to the specified alternative hypothesis.

estimate

the estimated mean vector or vectors depending on whether it was a one-sample test or a two-sample test.

null.value

the specified hypothesized value of the mean or mean difference depending on whether it was a one-sample test or a two-sample test.

alternative

a character string describing the alternative hypothesis.

method

a character string indicating what type of T2-test was performed.

data.name

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

Arguments

x

a (non-empty) numeric data frame or matrix.

y

an optional (non-empty) numeric data frame or matrix.

mu

an optional (non-empty) numeric vector of data values (or a single number which will be repeated p times) indicating the true value of the mean (or difference in means if you are performing a two sample test).

conf.level

confidence level of the interval

method

the method to be used - 'c' for sample mean and covariance matrix and 'mcd' for minimum covariance determinant estimator. A two-sample MCD based T2-test is not yet implemented.

formula

a formula of the form lhs ~ rhs where lhs is a numeric data frame or matrix giving the observations 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 (currently not used)

na.action

a function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action") (currently only "na.rm" used)

...

further arguments to be passed to or from methods.

Author

Valentin Todorov valentin.todorov@chello.at

Details

The formula interface is only applicable for the two-sample tests.

References

Willems G., Pison G., Rousseeuw P. and Van Aelst S. (2002), A robust hotelling test, Metrika, 55, 125--138.

See Also

CovMcd

Examples

Run this code

## One-sample classical test
data(delivery)
delivery.x <- delivery[,1:2]
T2.test(delivery.x)

## One-sample robust test
data(delivery)
delivery.x <- delivery[,1:2]
T2.test(delivery.x, method="mcd")

## Two-sample classical test
data(hemophilia)
grp <-as.factor(hemophilia[,3])
x <- hemophilia[which(grp==levels(grp)[1]),1:2]
y <- hemophilia[which(grp==levels(grp)[2]),1:2]
T2.test(x,y)

## or using the formula interface
T2.test(as.matrix(hemophilia[,-3])~hemophilia[,3])


if (FALSE) {
## Two-sample robust test
T2.test(x,y, method="mcd")    ## error - not yet implemented
}

Run the code above in your browser using DataLab