Statistics & probability

Box M covariance equality test calculator from multivariate group observations

Compare independent multivariate group covariance matrices using Box M and its stated chi-square approximation.

Your numbers

Valid JSON.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Box's M tests whether several multivariate groups share the same population covariance matrix. It concerns how variables vary together within groups, rather than whether the groups have the same mean vector.

THE FORMULAFor g groups of p-dimensional observations calculate unbiased S_i with df v_i=n_i-1; V=sumv_i; pooled S=Σv_iS_i/V. M=V logdetS -Σv_i logdetS_i. c=[(2p²+3p-1)/(6(p+1)(g-1))]*(Σ1/v_i-1/V). ChiSquare=(1-c)M, df=(g-1)p(p+1)/2; chi-square survival only if approximation valid. Cholesky logdet and explicit PD check; singularcovariancereject. Do not silentlyregularizeinput.

A worked example

With the prefilled inputs, M = 0.

Good to know

Approximate chi-square reference under independent multivariate normal samples; sensitive to nonnormality. No exact finite-sample p-value.

Compare covariance structures

Box's M tests whether several multivariate groups share the same population covariance matrix. It concerns how variables vary together within groups, rather than whether the groups have the same mean vector.

A difference in location alone should not create a covariance difference. Each group's observations are therefore centered on their own group mean before its sample covariance is calculated.

BoxM translation invarianceA mean shift preserves within-group covarianceGroup 1same covarianceGroup 2same covarianceshiftS₁ = S₂ = [[4/3, −2/3], [−2/3, 4/3]]; M = 0
Scroll across to see the full diagram.
Translating the triangle(0,0),(2,0),(0,2) by(1,1) leaves its covariance unchanged. Ellipse orientations and axes depict the shared covariance; the mean shift is schematic.

Compare with the Mardia multivariate skewness and kurtosis test calculator. Compare covariance matrices across groups; Mardia tests multivariate normality within a single sample rather than equality of group scatter.

Prepare aligned multivariate rows

Use the prefilled input structure and preserve the declared column or index order. Every observation needs the same variable order and units. Group labels define independent samples, while columns define the multivariate coordinates whose variances and covariances will be compared.

Each group needs more observations than variables for an ordinary nonsingular sample covariance. Exact linear relationships between columns can still cause singularity despite an apparently sufficient row count. The interface expects an array of group matrices with the same two to five variables in every row. The number of groups lies between two and six, the pooled row count is at most five hundred, and every group must contain more observations than the dimension plus two. Units and variable order must match across groups. A constant column or exact linear relationship creates a singular covariance matrix and prevents the log-determinant calculation. Adding an undocumented ridge term would change the hypothesis being tested, so this page rejects that situation rather than disguising the covariance problem.

Pool covariance with residual degrees of freedom

The pooled matrix weights each group covariance by n-minus-one and divides by the combined residual degrees of freedom. This is the covariance estimate under the common-matrix hypothesis.

Weighting covariance matrices equally would describe a different estimator when group sizes differ. The displayed pooled matrix should retain the group sizes so that this weighting can be checked.

Use logarithmic determinants

The raw M statistic contrasts the log determinant of the pooled matrix with the weighted log determinants of the separate matrices. Determinants summarize generalized variance rather than individual diagonal entries alone.

A small-sample correction turns the raw statistic into an approximate chi-square reference quantity. Its validity depends on the approximation and multivariate-normal sampling assumptions, not merely on obtaining a positive number.

An unchanged-covariance check

Take points(0,0),(2,0),(0,2) in one group and shift every coordinate by one to obtain the second group. Both unbiased covariance matrices are[[4/3,-2/3],[-2/3,4/3]].

Because the pooled matrix equals each group matrix, M is zero. With two groups and two variables, the reference degrees of freedom are three and the corresponding upper-tail p-value is one.

Treat singularity as information

A singular covariance has no finite log determinant for this calculation. It can indicate a redundant variable, too few observations or data constrained to a lower-dimensional subspace.

Adding a hidden diagonal ridge would change the hypothesis being tested. Resolve the variable representation or use a method designed for singular data rather than presenting a regularized number as ordinary Box's M. Group sizes enter both the pooled covariance and the Bartlett adjustment. Duplicating every observation changes those degrees of freedom even when a plotted point cloud appears unchanged.

Evaluate assumptions before conclusions

The test can react strongly to departures from multivariate normality. A small p-value may reflect those distributional issues as well as covariance differences.

Inspect group-specific matrices and data plots alongside the omnibus result. A rejection identifies neither the responsible covariance entry nor a scientifically meaningful size of difference by itself. Each group covariance uses its ordinary sample divisor n minus one. The pooled covariance weights those matrices by their residual degrees of freedom, not by equal group weights. The uncorrected M statistic combines the pooled and within-group log determinants; the displayed correction uses both the dimension and the unequal group sizes. Output includes the approximate chi-square statistic and its degrees of freedom, but this version does not return a tail p-value. The reference distribution assumes independent multivariate-normal samples. Severe outliers, skewness or dependence can invalidate that approximation even if all the determinant computations are numerically stable. Approximate chi-square reference under independent multivariate normal samples; sensitive to nonnormality. No exact finite-sample p-value.

A few questions, answered

Does this test whether the means are equal?

No. It compares within-group covariance matrices after centering each group separately.

Why is my covariance singular?

Common causes are redundant columns, exact relationships or too few independent observations for the chosen dimension.

Can I replace a missing observation with zero?

No. Zero is a real numerical value and would change means and covariance; missing-data handling needs an explicit policy.

Is the chi-square reference exact?

No. It is an approximation under the stated sampling and distributional assumptions.

Find your calculator

Start typing to explore the library.