BCompare groups · Guide test 159
Bartlett sphericity test for correlations
Tests whether a population correlation matrix equals the identity matrix.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Exploratory factor analysis — Which few underlying factors explain how a set of items or measures correlate?
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
Your data
Simulated with a known ρIf H₀ were true
- The reference: how χ² varies across samples when H₀ is true.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .012).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- 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 H₀.
Question and hypotheses
H0: the population correlation matrix is the identity.
Assumptions
Independent approximately multivariate normal observations; nonsingular sample correlation matrix.
Formula
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.
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
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
- psych — psych · cortest.bartlettAuthor documentation/source reviewed: psych 2.6.9.search.r-project.org
- cortest.bartlettsearch.r-project.org
- 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.