Learn R Programming

rrcov (version 0.4-01)

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 class 'default':
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, \dots)

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(for
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.

Value

  • A list with class "htest" containing the following components:
  • statisticthe value of the T2-statistic.
  • parameterthe degrees of freedom for the T2-statistic.
  • p.valuethe p-value for the test.
  • conf.inta confidence interval for the mean vector appropriate to the specified alternative hypothesis.
  • estimatethe estimated mean vector or vectors depending on whether it was a one-sample test or a two-sample test.
  • null.valuethe specified hypothesized value of the mean or mean difference depending on whether it was a one-sample test or a two-sample test.
  • alternativea character string describing the alternative hypothesis.
  • methoda character string indicating what type of T2-test was performed.
  • data.namea character string giving the name(s) of the data.

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 robust test
data(delivery)
delivery.x <- delivery[,1:2]
T2.test(delivery.x, method="mcd")

## Two-sample robust 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])


T2.test(x,y, method="mcd")    ## error - not yet implemented

Run the code above in your browser using DataLab