Box's M test for equality of two or more covariance matrices.
Mtest.cov(x, ina, a = 0.05)
A vector with the the test statistic, the p-value, the degrees of freedom and the critical value of the test.
A matrix containing Euclidean data.
A vector denoting the groups of the data.
The significance level, set to 0.05 by default.
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
According to Mardia, Kent and Bibby (1979, pg. 140), it may be argued that if \(n_i\) is small, then the log-likelihood ratio test (function likel.cov
) gives too much weight to the contribution of \({\bf S}\). This consideration led Box (1949) to propose another test statistic in place of that seen in likel.cov
. Box's \(M\) is given by
$$
M=\gamma\sum_{i=1}^k\left(n_i-1\right)\log{\left|{\bf S}_{i}^{-1}{\bf S}_p \right|},
$$
where \(\gamma=1-\frac{2p^2+3p-1}{6\left(p+1\right)\left(k-1\right)}\left(\sum_{i=1}^k\frac{1}{n_i-1}-\frac{1}{n-k}\right)\) and \({\bf S}_{i}\) and \({\bf S}_{p}\) are the \(i\)-th unbiased covariance estimator and the pooled covariance matrix, respectively with \({\bf S}_p=\frac{\sum_{i=1}^k\left(n_i-1\right){\bf S}_i}{n-k}\). Box's \(M\) also has an asymptotic \(\chi^2\) distribution with \(\frac{1}{2}\left(p+1\right)\left(k-1\right)\) degrees of freedom. Box's approximation seems to be good if each \(n_i\) exceeds 20 and if \(k\) and \(p\) do not exceed 5 (Bibby and Kent (1979) pg. 140).
Mardia K.V., Kent J.T. and Bibby J.M. (1979). Multivariate Analysis. London: Academic Press.
equal.cov, likel.cov
x <- as.matrix( iris[, 1:4] )
ina <- iris[, 5]
Mtest.cov(x, ina)
Run the code above in your browser using DataLab