Skip to content

CAssociation · Guide test 082

Williams test

Compares two dependent correlations that share a variable within the same sample.

Runs in CodeSplashPython (calls R) example not runR example validated

Do it in CodeSplash

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

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

40
0.55
0.20
0.40
0.050

Alternative

Your data

Simulated with known correlations
#xyz
1.000−0.916−0.686−1.104
2.000−0.0330.7380.824
3.0000.201−0.0640.266
4.0000.3070.551−1.076
5.0000.7620.8241.715
6.0000.4420.333−1.354
7.0000.207−0.591−0.606
8.0002.3300.6570.308
9.000−0.0920.445−0.125
10.0001.6961.290−0.049
11.000−0.139−0.7900.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

t = 3.53
  1. The reference: how t 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 = .001).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

t=(rxy−rxz)(n−1)(1+ryz)2n−1n−3∣R∣+rˉ2(1−ryz)3t=(r_{xy}-r_{xz})\sqrt{\dfrac{(n-1)(1+r_{yz})}{2\frac{n-1}{n-3}|R|+\bar r^2(1-r_{yz})^3}}

With your numbers

t=3.53,n−3=37,∣R∣=0.65t = 3.53,\qquad n-3 = 37,\qquad |R| = 0.65
∣R∣|R|
determinant of the 3 × 3 correlation matrix
rˉ\bar r
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 H0.

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

t=(rXY−rXZ)(n−1)(1+rYZ)2n−1n−3∣R∣+rˉ2(1−rYZ)3t=(r_{XY}-r_{XZ})\sqrt{\frac{(n-1)(1+r_{YZ})}{2\frac{n-1}{n-3}|R|+\bar r^2(1-r_{YZ})^3}}

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.

Python · invokes R

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()
R

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

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.