| boxM | R Documentation |
boxM() performs the Box's (1949) M-test 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 chi-square approximation.
boxM(Y, ...)
## S3 method for class 'formula'
boxM(Y, data, ...)
## S3 method for class 'lm'
boxM(Y, ...)
## Default S3 method:
boxM(Y, group, ...)
## S3 method for class 'boxM'
print(x, ...)
## S3 method for class 'boxM'
summary(
object,
digits = getOption("digits") - 2,
cov = FALSE,
quiet = FALSE,
...
)
Y |
The response variable matrix for the default method, or a |
... |
Other arguments passed down |
data |
A data frame containing the variables in the model. Used only for the formula method. |
group |
A vector specifying the groups. Used only for the default method. |
x |
a class |
object |
A |
digits |
Number of digits in printed output |
cov |
Logical; if |
quiet |
Logical; if |
As an object of class "boxM", a few methods are
available: print.boxM(), summary.boxM() and plot.boxM().
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 non-singular, 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 recommend to ignore the result unless it is very highly significant, e.g., p < .0001 or worse.
In general, heterogeneity of covariance matrices can be more easily seen and understood by plotting
the covariance ellipses using covEllipses.
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:
the vector of log determinants
eigenvalues of the covariance matrices
statistics computed on the eigenvalues for each covariance matrix:
the product of eigenvalues, \prod{\lambda_i}
the sum of eigenvalues, \sum{\lambda_i}
the average precision of eigenvalues,
1/\sum(1/\lambda_i)
the maximum eigenvalue, \lambda_1
A list with class c("boxM", "htest") containing the following
components:
statistic |
the chi-square (approximate) statistic for Box's M test, where large values imply the covariance matrices differ. |
parameter |
the degrees of freedom for the test statistic. |
p.value |
the p-value of the test |
ngroups |
the number of levels of the |
cov |
a list of the group covariance matrices, of length |
pooled |
the pooled covariance matrix |
means |
a matrix whose |
logDet |
a vector of length |
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, as extracted from the call |
method |
the character string |
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, 317-346.
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 dot plot of the log determinants compared with that of the pooled covariance matrix, and also of other quantities computed from their eigenvalues
covEllipses plots covariance ellipses in variable space for
several groups.
data(iris)
# default method, using `Y`, `group`
res <- boxM(iris[, 1:4], iris[, "Species"])
res
# summary method gives details
summary(res)
# visualize (this is 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"))
# plot method gives confidence intervals for logDet
plot(res, gplabel="Species")
# formula method
boxM( cbind(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width) ~ Species,
data=iris)
### Skulls data
data(Skulls)
# lm method
skulls.mod <- lm(cbind(mb, bh, bl, nh) ~ epoch, data=Skulls)
skulls.boxM <- boxM(skulls.mod) |>
print()
summary(skulls.boxM)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.