Box’s M compares group covariance matrices using pooled log determinants. Work through its correction and learn why normality, outliers and power matter.
Box M test
The Box M test, usually called Box’s M test, tests whether several populations have the same covariance matrix. For a quant comparing groups of asset returns or model residuals, it asks whether their joint spread can plausibly share one covariance model. It does not test whether their average returns are equal.
For g groups of p variables, the null hypothesis is
H0:Σ1=Σ2=⋯=Σg.
The group means may differ under this null. Each group is centred on its own mean before its covariance is calculated. A test of mean vectors, such as MANOVA, addresses a different hypothesis. Friendly and Sigal, §§1.2–1.3, distinguish these questions.
Compare the pooled model with separate models
Assume independent groups, with independent observations from a multivariate normal distribution within each group. Write ni for group size, N=∑ini, and use the usual sample covariance, with divisor ni−1:
Si=ni−11j=1∑ni(xij−xˉi)(xij−xˉi)⊤.
The pooled within-group covariance is
SP=N−g∑i=1g(ni−1)Si.
This is not the covariance obtained by ignoring group labels and centring every observation on one grand mean: that would also include between-group mean differences.
Define the uncorrected log-determinant statistic here as
M=(N−g)lndetSP−i=1∑g(ni−1)lndetSi.
The determinant summarises multivariate scatter. The comparison uses the determinant of the pooled matrix, not merely a check that the separate determinants match. Equal determinants can conceal different matrix shapes. Large M indicates greater disagreement with a common covariance model.
degrees of freedom. Under the null and the approximation’s assumptions, compare X2 with the upper tail of χν2.
Check the reporting convention. Here M already means the displayed log-determinant difference; do not apply another −2ln to it. Some software reports only the corrected X2, and other presentations use an F approximation. The heplots implementation uses the correction above and labels its result “Chi-Sq (approx.)”.
Two variables, four times the variance
Consider fictional summaries from two independent normal groups, each with 20 observations of two dimensionless variables. Suppose their sample covariances, using divisor 19, are
S1=I2,S2=4I2.
Both have zero sample cross-covariance; group 2 has four times each marginal sample variance. Pooling gives
SP=3819I2+19(4I2)=2.5I2.
Thus detS1=1, detS2=16, and detSP=6.25. The calculation is
The chi-squared approximation gives a p-value of about 0.00114. This is evidence against equal population covariances within the stipulated normal, independent-sample model; it is not an exact small-sample probability or a probability that the null is true.
Fictional two-variable example with 20 observations per group. Covariance contours for I and 4I have radii 1 and 2, while pooled 2.5I has radius square root 2.5. Pooled log determinant 1.83258 exceeds weighted group log determinant 1.38629. Multiplying the gap by 38 gives raw M 16.95891; the corrected statistic is 15.99195 with 3 degrees of freedom.
Original fictional covariance summaries. The contours are centred separately to compare spread; they are not confidence regions for group means. The lower panel shows the gap that produces raw M.
What a result cannot settle
Box’s M is sensitive to non-normality and outliers, and unbalanced group sizes can worsen its behaviour. A rejection in heavy-tailed return data may reflect poor calibration of the normal-theory reference distribution. Serial dependence also violates the independent-observation model. These concerns belong in the interpretation, alongside group covariance plots. See Friendly and Sigal, §§1.3–1.4, and the official heplots details.
The ordinary calculation requires positive-definite group covariance matrices. Having ni>p is necessary for a full-rank sample covariance, but redundant variables can still make it singular. Near-singularity also makes log determinants numerically fragile; a stable factorisation helps computation but does not repair the sampling model.
A non-rejection does not prove equality: statistical power depends on sample sizes, dimension and the alternatives. Nor is “passing Box’s M” a universal gate before using a robust method. Choose an analysis suited to the target question and data structure; a preliminary covariance test alone cannot establish its validity.
For the covariance quantities being compared, Expectation, Variance and Covariance develops the link between co-movement and portfolio variance. The public page is a preview; full access requires a free signed-in account.
heplots authors, R/boxM.R, pinned revision 0b906346: pooled covariance, raw log-determinant calculation, correction factor and upper-tail inference. The explicit raw-M convention above follows this computation.