Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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, ...)

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

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

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.

Details

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

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.

Author(s)

Valentin Todorov valentin.todorov@chello.at

References

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

See Also

Examples

## 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])


## Not run: 
## Two-sample robust test
T2.test(x,y, method="mcd")    ## error - not yet implemented

## End(Not run)

rrcov

Scalable Robust Estimators with High Breakdown Point

v1.5-5
GPL (>= 2)
Authors
Valentin Todorov [aut, cre] (<https://orcid.org/0000-0003-4215-0245>)
Initial release
2020-07-31

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.