Skip to contents

Test whether the mean vectors of multiple multivariate normal populations are all equal when the covariance matrices are equal. Suppose we have k populations, the null hypothesis is that "H0: mu1 = mu2 = ... = muk". There are two approximations (Bartlett's chi2 and Rao's F) to compute the p-value and the critical value. The realized value of the Wilks Lambda statistic and its degrees of freedom are also provided. If you want to perform an exact test, consult the Wilks Lambda statistic quantile table yourself, depending on the realized value of the statistic and its degrees of freedom.

Usage

meanTest.multi(X, label, alpha = 0.05, verbose = TRUE)

Arguments

X

The data matrix which is a matrix or data frame.

label

A vector of group labels.

alpha

The significance level. Default is 0.05.

verbose

A boolean value. Default is TRUE. If TRUE, the null hypothesis will be displayed. If FALSE, the test will be carried out silently.

Value

An object of class "testResult", which is a list with the following elements:

Conclusion

The conclusion of the test.

Stat

A data frame containing the statistics, p value and critical value.

SampMeanT

The sample mean.

SampMeanWithin

The sample mean of each group.

SdTotal

The total sample deviation.

SdBetween

The sample deviation between group.

SdWithin

The sample deviation of each group.

SdWithinT

The sample deviation within group.

Df

The degree of freedom.

sampleSize

The sample size of each group.

References

Huixuan, Gao. Applied Multivariate Statistical Analysis. Peking University Press, 2005: pp.80-83.

Author

Xifeng Zhang

Examples

data(iris)
chart <- iris[, 1:4]
species <- iris[, 5]
# carry out the test
test1 <- meanTest.multi(chart, species)
test2 <- meanTest.multi(chart, species, verbose = FALSE)
#> H0: mu1 = mu2 = ... = muk, k = 3
# get the elements
test1$Stat
#>                        Value p.value   Critical.Value
#> Wilks Lambda    2.343863e-02                         
#> Bartlett's Chi2 5.461153e+02       0 15.5073130558655
#> Rao's F         1.274530e+04       0  1.9706194163219
test1$SampMeanT
#> Sepal.Length  Sepal.Width Petal.Length  Petal.Width 
#>     5.843333     3.057333     3.758000     1.199333 
test1$sampleSize
#>     setosa versicolor  virginica 
#>         50         50         50