Skip to content

BCompare groups · Guide test 159

Bartlett sphericity test for correlations

Tests whether a population correlation matrix equals the identity matrix.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Bartlett sphericity test for correlations

50
0.00
0.00
0.35
0.00
0.050

Your data

Simulated with a known ρ

If H₀ were true

χ² = 6.37
  1. The reference: how χ² varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .012).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

χ2=−(n−1−2p+56)ln⁡∣R∣,ν=p(p−1)2\chi^2 = -\left(n-1-\tfrac{2p+5}{6}\right)\ln|\mathbf R|,\qquad \nu = \tfrac{p(p-1)}{2}

With your numbers

χ2=6.37,r=0.35\chi^2 = 6.37,\quad r = 0.35
∣R∣|\mathbf R|
determinant of the correlation matrix (1 − r² for two variables)

The verdict

χ²(1) = 6.37, p = .012

p ≤ α = .050: reject H₀

A gate before factor analysis: if variables are uncorrelated there are no factors to find. With large n it nearly always rejects.

Statistic
6.368
p-value
0.0116
Bartlett sphericity test for correlations on 50 (x, y) pairs: χ²(1) = 6.37, p = .012. The p-value is below α = .050, so the data are hard to reconcile with H0.

Bartlett sphericity test for correlations on 50 (x, y) pairs: χ²(1) = 6.37, p = .012. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: the population correlation matrix is the identity.

Assumptions

Independent approximately multivariate normal observations; nonsingular sample correlation matrix.

Formula

X2=−[n−1−2p+56]log⁡∣R∣X^2=-\left[n-1-\frac{2p+5}{6}\right]\log|R|

Parameters and notation

R is the p×p sample correlation matrix; df=p(p−1)/2.

Structure of the method

Estimate a sample correlation matrix and convert its negative log determinant into a corrected chi-square statistic. Under an identity population correlation, the off-diagonal correlations vanish; this differs from testing equality of all covariance eigenvalues in repeated-measures contrast space.

Estimated and nuisance parameters

Estimate variable means, scales and pairwise correlations. The null matrix is fixed as identity. The sample size must correspond to the observations supporting that correlation estimate, not a convenient software default.

Settings and design choices

Choose variables, missing-data treatment, significance level and determinant computation. Pairwise deletion can produce correlations based on different n or a non-positive-definite matrix; blindly passing one sample size can be inappropriate.

Fitting and adaptation

For new data re-estimate the correlation matrix and use its actual sample size. Transformations or selecting variables based on their correlations create additional selection issues. Neural fine-tuning is not relevant. Rejection establishes some correlation under the assumptions, not the fit, factor count, interpretability or adequacy of a proposed factor model.

Sensitivity and robustness

Redundant variables and small n can make log determinants unstable or singular. Heavy tails and dependent observations affect the chi-square approximation. A large sample can reject identity for tiny correlations, while nonrejection may reflect low power; report correlation magnitudes and uncertainty alongside the global test.

How to use and calibrate

Use an upper χ²df tail. A rejection indicates some correlation among variables.

Example application

Evaluate whether a set of variables departs from an uncorrelated structure.

Interpretation and pitfalls

Watch out

This is not Mauchly sphericity or Bartlett variance homogeneity. Rejection alone does not establish that a factor model fits.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

Tests identity of the population correlation matrix, not repeated-measures sphericity.

Python · native

Validated — Executed successfully in the validation environment · needs numpy, scipy

import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
X=rng.normal(size=(40,3));Y=rng.normal(.3,1,size=(50,3))
n,p=X.shape;T=-(n-1-(2*p+5)/6)*np.linalg.slogdet(np.corrcoef(X,rowvar=False))[1]
print(T,stats.chi2.sf(T,p*(p-1)/2))
Output
2.0813557397390166 0.5556938232690742
R

Validated — Executed successfully in the validation environment · needs psych

set.seed(2026)
X<-matrix(rnorm(120),ncol=3);Y<-matrix(rnorm(150,mean=.3),ncol=3)
print(psych::cortest.bartlett(cor(X),n=nrow(X)))
Output
$chisq
[1] 7.277134

$p.value
[1] 0.06357

$df
[1] 3

Sources

Statistics guide v4 (historical):
R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 159, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT159.