Last chance! 50% off unlimited learning
Sale ends in
Classical and Robust One-way MANOVA: Wilks Lambda
# S3 method for formula
Wilks.test(formula, data, ..., subset, na.action)# S3 method for default
Wilks.test(x, grouping, method=c("c", "mcd", "rank"),
approximation=c("Bartlett", "Rao", "empirical"),
xd=NULL, xq=NULL, xfn = NULL, xwl=NULL, nrep=3000, trace=FALSE, ...)
# S3 method for data.frame
Wilks.test(x, ...)
# S3 method for matrix
Wilks.test(x, grouping, ..., subset, na.action)
A list with class "htest"
containing the following components:
the value of the Wilks' Lambda statistic.
The corresponding approximation of the Wilks' lambda statistic and the degrees of freedom.
the p-value for the test.
the estimated mean vectors.
a character string indicating what type of test was performed.
a character string giving the name of the data.
multiplication factor for the approximate distribution of the robust Lambda statistic.
the degrees of freedom for the approximate
A formula of the form groups ~ x1 + x2 + ...
That is, the
response is the grouping factor and the right hand side specifies
the (non-factor) variables.
Data frame from which variables specified in formula
are
to be taken.
(required if no formula is given as the principal argument.) a matrix or data frame or Matrix containing the explanatory variables.
grouping variable - a factor specifying the class for each observation (required if no formula argument is given.)
An index vector specifying the cases to be used.
A function to specify the action to be taken if NA
s are found.
The default action is for the procedure to fail. An alternative is
na.omit
, which leads to rejection of cases with missing values on
any required variable.
"c"
for standard estimators of the mean and variance,
"mcd"
for MCD estimators of mean and variances and
"rank"
for rank based wilks' lambda as proposed by Nath and Pavur (1985).
"Bartlett"
for Bartlett approximation (default),
"Rao"
for rao approximation (only for method="c") and
"empirical"
for simulated empirical distribution.
multiplication factor for the approximate distribution of
the robust Lambda statistic. If xd=NULL
the factor will
computed by simulation and will be returned in the value (see Details)
the degrees of freedom for the approximate xq=NULL
the degrees of freedom will
computed by simulation and will be returned in the value (see Details)
the empirical distribution function. If xfn=NULL
the empirical function will
be estimated by simulation and will be returned in the value (see Details)
the simulated values of the robust statistic. If xwl=NULL
the simulation
will be performed and the calculated result will be returned in the value (see Details)
number of trials for the simulations for computing the
multiplication factor xd
and the degrees of freedom xq
. Default is nrep=3000
.
whether to print intermediate results. Default is trace = FALSE
arguments passed to or from other methods.
Valentin Todorov valentin.todorov@chello.at
The classical Wilks' Lambda statistic for testing the equality of
the group means of two or more groups is modified into a robust
one through substituting the classical estimates by the highly robust
and efficient reweighted MCD estimates, which can be computed efficiently
by the FAST-MCD algorithm - see CovMcd
.
An approximation for the finite sample distribution of the
Lambda statistic is obtained, based on matching the mean and
variance of a multiple of an
Todorov, V. and Filzmoser, P. (2007) Robust statistic for the one-way MANOVA, submetted to the Journal of Environmetrics.
Todorov, V. (2007) Robust selection of variables in linear discriminant analysis, Statistical Methods and Applications, 15, 395.407, doi:10.1007/s10260-006-0032-6.
Nath, R. and Pavur, R. (1985) A new statistic in the one way multivariate analysis of variance, Computatational Statistics and Data Analysis, 2, 297--315
CovMcd
, T2.test
library(MASS)
data(anorexia)
grp <- as.factor(anorexia[,1])
x <- as.matrix(anorexia[,2:3])
## Using the default interface, classical test
Wilks.test(x, grouping=grp, method="c")
## Using the default interface, rank based test
Wilks.test(x, grouping=grp, method="rank")
## For this data set: p=2, n=n1+n2+n3=29+26+17
## were computed the following multiplication factor xd and degrees of freedom xq
## for the MCD estimates with alpha=0.5
xd <- -0.02162666
xq <- 3.63971
Wilks.test(x, grouping=grp, method="mcd", xd=xd, xq=xq)
## Now the same with the formula interface
Wilks.test(Treat~Prewt+Postwt, data=anorexia, method="mcd", xd=xd, xq=xq)
##Iris data with formula interface
data(iris)
Wilks.test(Species~., data=iris, method="c")
## and with default interface
Wilks.test(iris[,1:4],grouping=iris[,5], method="c")
# hemophilia data - classical, rank and MCD test
data(hemophilia)
hemophilia$gr <- as.factor(hemophilia$gr)
Wilks.test(gr~., data=hemophilia, method="c")
Wilks.test(gr~., data=hemophilia, method="rank")
## already simulated parameters for MCD with alpha=0.5
xd <- -0.01805436
xq <- 1.950301
Wilks.test(gr~., data=hemophilia, xd=xd, xq=xq, method="mcd")
Run the code above in your browser using DataLab