box.mtest: Box's M test

Description Usage Arguments Value Author(s) Examples

View source: R/box.mtest.R

Description

Chi-square approximation to Box's M test for equality of k covariance matrices, as described in Rencher (2002, p255).

Usage

1
box.mtest(covmats, nvec)

Arguments

covmats

Array of k covariance matrices to be tested for equality.

nvec

Vector of sample sizes of the k groups.

Value

Returns a list with the values

p.value

The p value for the test.

S.pooled

Pooled covariance matrix as used in the M-test, under the assumption of equal population covariance matrices.

Author(s)

Theo Pepler

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Iris data
data(iris)
iris1 <- subset(iris, Species == 'setosa')
iris2 <- subset(iris, Species == 'versicolor')
iris3 <- subset(iris, Species == 'virginica')
## Array containing the covariance matrices
S <- array(NA, dim = c(4, 4, 3))
S[, , 1] <- cov(iris1[, 1:4])
S[, , 2] <- cov(iris2[, 1:4])
S[, , 3] <- cov(iris3[, 1:4])
## Box's M-test
box.mtest(covmats = S, nvec = c(50, 50, 50))

tpepler/theolib documentation built on Aug. 10, 2021, 9:53 a.m.