boxM
performs the Box's (1949) Mtest for homogeneity of covariance matrices
obtained from multivariate normal data according to one or more classification
factors. The test compares the product of the log determinants of the
separate covariance matrices to the log determinant of the pooled
covariance matrix, analogous to a likelihood ratio test.
The test statistic uses a chisquare approximation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
Y 
The response variable matrix for the default method, or a 
data 
a numeric data.frame or matrix containing n observations of p variables; it is expected that n > p. 
group 
a factor defining groups, or a vector of length n doing the same. 
object 
a 
digits 
number of digits to print for the 
cov 
logical; if 
quiet 
logical; if 
... 
Arguments passed down to methods. 
As an object of class "htest"
, the statistical test is printed normally by default.
As an object of class "boxM"
, a few methods are available.
There is no general provision as yet for handling missing data. Missing data are simply removed, with a warning.
As well, the computation assumes that the covariance matrix for each group is nonsingular, so that log det(S_i) can be calculated for each group. At the minimum, this requires that n > p for each group.
Box's M test for a multivariate linear model highly sensitive to departures from multivariate normality, just as the analogous univariate test. It is also affected adversely by unbalanced designs. Some people reccommend to ignore the result unless it is very highly significant, e.g., p < .0001 or worse.
The summary
method prints a variety of additional statistics based on the eigenvalues of
the covariance matrices. These are returned invisibly, as a list containing the following
components:
logDet
 log determinants
eigs
 eigenvalues of the covariance matrices
eigstats
 statistics computed on the eigenvalues for each covariance matrix:
product
: the product of eigenvalues, ∏{λ_i};
sum
: the sum of eigenvalues, ∑{λ_i};
precision
: the average precision of eigenvalues, 1/∑(1/λ_i);
max
: the maximum eigenvalue, λ_1
A list with class c("htest", "boxM")
containing the following components:
statistic 
an approximated value of the chisquare distribution. 
parameter 
the degrees of freedom related of the test statistic in this case that it follows a Chisquare distribution. 
p.value 
the pvalue of the test. 
cov 
a list containing the within covariance matrix for each level of 
pooled 
the pooled covariance matrix. 
logDet 
a vector containing the natural logarithm of each matrix in 
means 
a matrix of the means for all groups, followed by the grand means 
df 
a vector of the degrees of freedom for all groups, followed by that for the pooled covariance matrix 
data.name 
a character string giving the names of the data. 
method 
the character string "Box's Mtest for Homogeneity of Covariance Matrices". 
The default method was taken from the biotools package, Anderson Rodrigo da Silva <anderson.agro@hotmail.com>
Generalized by Michael Friendly and John Fox
Box, G. E. P. (1949). A general distribution theory for a class of likelihood criteria. Biometrika, 36, 317346.
Morrison, D.F. (1976) Multivariate Statistical Methods.
leveneTest
carries out homogeneity of variance tests for
univariate models with better statistical properties.
plot.boxM
, a simple plot of the log determinants
covEllipses
plots covariance ellipses in variable space for several groups.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25  data(iris)
# default method
res < boxM(iris[, 1:4], iris[, "Species"])
res
summary(res)
# visualize (what is done in the plot method)
dets < res$logDet
ng < length(res$logDet)1
dotchart(dets, xlab = "log determinant")
points(dets , 1:4,
cex=c(rep(1.5, ng), 2.5),
pch=c(rep(16, ng), 15),
col= c(rep("blue", ng), "red"))
# formula method
boxM( cbind(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width) ~ Species, data=iris)
### Skulls dat
data(Skulls)
# lm method
skulls.mod < lm(cbind(mb, bh, bl, nh) ~ epoch, data=Skulls)
boxM(skulls.mod)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.