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

Wilks.test

Classical and Robust One-way MANOVA: Wilks Lambda


Description

Classical and Robust One-way MANOVA: Wilks Lambda

Usage

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

## Default S3 method:
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 class 'data.frame'
Wilks.test(x, ...)

## S3 method for class 'matrix'
Wilks.test(x, grouping, ..., subset, na.action)

Arguments

formula

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

Data frame from which variables specified in formula are to be taken.

x

(required if no formula is given as the principal argument.) a matrix or data frame or Matrix containing the explanatory variables.

grouping

grouping variable - a factor specifying the class for each observation (required if no formula argument is given.)

subset

An index vector specifying the cases to be used.

na.action

A function to specify the action to be taken if NAs 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.

method

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

approximation

"Bartlett" for Bartlett approximation (default), "Rao" for rao approximation (only for method="c") and "empirical" for simulated empirical distribution.

xd

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)

xq

the degrees of freedom for the approximate χ^2 distribution of the robust Lambda statistic. If xq=NULL the degrees of freedom will computed by simulation and will be returned in the value (see Details)

xfn

the empirical distribution function. If xfn=NULL the empirical function will be estimated by simulation and will be returned in the value (see Details)

xwl

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)

nrep

number of trials for the simulations for computing the multiplication factor xd and the degrees of freedom xq. Default is nrep=3000.

trace

whether to print intermediate results. Default is trace = FALSE

...

arguments passed to or from other methods.

Details

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 χ^2 distribution which are computed by simultaion.

Value

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

statistic

the value of the Wilks' Lambda statistic.

parameter

The corresponding approximation of the Wilks' lambda statistic and the degrees of freedom.

p.value

the p-value for the test.

estimate

the estimated mean vectors.

method

a character string indicating what type of test was performed.

data.name

a character string giving the name of the data.

xd

multiplication factor for the approximate distribution of the robust Lambda statistic.

xq

the degrees of freedom for the approximate χ^2 distribution of the robust Lambda statistic.

Note

This function may be called giving either a formula and optional data frame, or a matrix and grouping factor as the first two arguments. All other arguments are optional.

Author(s)

Valentin Todorov valentin.todorov@chello.at

References

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

See Also

Examples

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")

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.