CAssociation · Guide test 082
Williams test
Compares two dependent correlations that share a variable within the same sample.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Compare two correlations (Fisher z, Williams, Steiger) — Is one correlation stronger than another?
In Compare two correlations (Fisher z, Williams, Steiger), choose Test = Williams' t (overlapping).
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 · Williams test
Alternative
Your data
Simulated with known correlations| # | x | y | z |
|---|---|---|---|
| 1.000 | −0.916 | −0.686 | −1.104 |
| 2.000 | −0.033 | 0.738 | 0.824 |
| 3.000 | 0.201 | −0.064 | 0.266 |
| 4.000 | 0.307 | 0.551 | −1.076 |
| 5.000 | 0.762 | 0.824 | 1.715 |
| 6.000 | 0.442 | 0.333 | −1.354 |
| 7.000 | 0.207 | −0.591 | −0.606 |
| 8.000 | 2.330 | 0.657 | 0.308 |
| 9.000 | −0.092 | 0.445 | −0.125 |
| 10.000 | 1.696 | 1.290 | −0.049 |
| 11.000 | −0.139 | −0.790 | 0.228 |
| 12.000 | −0.305 | −0.759 | −0.028 |
40 people measured on x, y and z · first 12 of 40 rows
If H₀ were true
- The reference: how t 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 = .001).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- determinant of the 3 × 3 correlation matrix
- the mean of r_xy and r_xz
The verdict
t(37) = 3.53, p = .001, Δr = 0.63
p ≤ α = .050: reject H₀
Effect size: r(x, y) − r(x, z) Δr = 0.635
Two correlations that share x come from the same people, so they are correlated themselves; Williams' t uses r_yz to account for that.
- Statistic
- 3.530
- p-value
- 0.0011
Williams test on 40 people measured on x, y and z: t(37) = 3.53, p = .001, Δr = 0.63. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: ρXY=ρXZ for two overlapping correlations from one sample.
Assumptions
Independent trivariate observations; approximate multivariate normality and a nonsingular correlation matrix.
Formula
Parameters and notation
R is the 3×3 sample correlation matrix; r̄=(rXY+rXZ)/2; df=n−3.
Structure of the method
Use all three correlations among a common target and two comparison variables to construct Williams’s overlapping-correlation t statistic. The correlation-matrix determinant and correlation between the two predictors adjust for their shared sampling variation; the reference uses n-3 degrees of freedom.
Estimated and nuisance parameters
Estimate rXY, rXZ, and rYZ on the same complete set of participants. Their joint correlation matrix must be positive semidefinite and sufficiently nonsingular. A supplied trio of arbitrary pairwise numbers may be impossible even when each lies between minus one and one.
Settings and design choices
Choose the overlapping-correlation hypothesis, direction, significance level, and the Williams variant explicitly. Pairwise deletion can produce inconsistent effective sample sizes and a nonvalid correlation matrix; use a stated common-case or model-based missing-data strategy.
Fitting and adaptation
Recompute the entire three-variable correlation matrix when observations change. A bootstrap resamples complete triples and recalculates all three correlations together. This is refitting, not fine-tuning. Replacing the shared-predictor correlation with zero falsely treats dependence as absent.
Sensitivity and robustness
Highly collinear comparison variables can make denominators unstable. Small samples and strong nonnormality challenge the t approximation. Equality of two correlations does not establish interchangeability of instruments, equal predictive error, or agreement in measurement scale.
How to use and calibrate
Use Williams’s t reference and specify the overlapping correlations being compared.
Example application
Test whether an outcome correlates more strongly with instrument A than instrument B in the same participants.
Interpretation and pitfalls
Watch out
The correlation between A and B is essential; using the independent Fisher z denominator is wrong.
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
Two overlapping correlations from the same sample; r.kh is the correlation between the two nonshared variables. The 3×3 correlation matrix must be feasible.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: cocor
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
print(cocor::cocor.dep.groups.overlap(r.jk=.5,r.jh=.3,r.kh=.2,n=100,test="williams1959"))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Validated — Executed successfully in the validation environment · needs cocor
print(cocor::cocor.dep.groups.overlap(r.jk=.5,r.jh=.3,r.kh=.2,n=100,test="williams1959"))
Output
Results of a comparison of two overlapping correlations based on dependent groups Comparison between r.jk = 0.5 and r.jh = 0.3 Difference: r.jk - r.jh = 0.2 Related correlation: r.kh = 0.2 Group size: n = 100 Null hypothesis: r.jk is equal to r.jh Alternative hypothesis: r.jk is not equal to r.jh (two-sided) Alpha: 0.05 williams1959: Williams' t (1959) t = 1.7980, df = 97, p-value = 0.0753 Null hypothesis retained
Sources
- cocor — cocor · cocor.dep.groups.overlapAuthor documentation/source reviewed: cocor 1.1-4.search.r-project.org
- cocor.dep.groups.overlapsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 082, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT082.