Skip to content

CAssociation · Guide test 089

Chatterjee xi independence test

Uses rank based xi to test independence, including nonmonotonic dependence under appropriate conditions.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

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

In Test for any dependence (ξ, Hoeffding, distance correlation, HSIC), choose Dependence measure = Chatterjee's ξ (y as a function of x).

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 · Chatterjee xi independence test

30

Shape of the link

0.80
0.050

Your data

Simulated with a known link

If H₀ were true

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

The formula

ξn=1−n∑i∣ri+1−ri∣2∑ili(n−li),z=n ξn/τ^\xi_n=1-\dfrac{n\sum_i|r_{i+1}-r_i|}{2\sum_i l_i(n-l_i)},\quad z=\sqrt{n}\,\xi_n/\hat\tau

With your numbers

ξn=0.20,z=1.69\xi_n = 0.20,\qquad z = 1.69
rir_i
ranks of y after sorting by x
lil_i
number of y values at least y_i
τ^2\hat\tau^2
tie-aware asymptotic variance

The verdict

ξ = 0.20, z = 1.69, p = .045, ξ = 0.20

p ≤ α = .050: reject H₀

Effect size: Chatterjee's xi (x → y) ξ = 0.196

ξ approaches 1 when y is a noiseless function of x and 0 under independence. It is asymmetric (x → y) and has modest power against linear links.

Statistic
1.691
p-value
0.0454
Chatterjee xi independence test on 30 (x, y) pairs: ξ = 0.20, z = 1.69, p = .045, ξ = 0.20. The p-value is below α = .050, so the data are hard to reconcile with H0.

Chatterjee xi independence test on 30 (x, y) pairs: ξ = 0.20, z = 1.69, p = .045, ξ = 0.20. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: X,Y are independent; the coefficient targets how strongly Y depends on X.

Assumptions

Independent paired observations. The simple formula and variance below require continuous variables without ties; use generalized handling otherwise.

Formula

ξn=1−3∑i=1n−1∣ri+1−ri∣n2−1Z=5n/2 ξn\begin{gathered}\xi_n=1-\frac{3\sum_{i=1}^{n-1}|r_{i+1}-r_i|}{n^2-1}\\[5pt] Z=\sqrt{5n/2}\,\xi_n\end{gathered}

Parameters and notation

Sort observations by X; ri is the rank of the corresponding Y. Under continuous independent margins, asymptotic Var(√n ξn)=2/5.

Structure of the method

Sort observations by the first variable and measure total variation in the ranks of the corresponding second variable. The resulting directional xi coefficient is standardized under an independence null, with a simple continuous-margin variance formula or a documented tie-aware alternative.

Estimated and nuisance parameters

Estimated quantities include the ordered rank sequence, xi, and any tie-dependent variance terms. The coefficient measures how Y depends on X; reversing the variable order defines another target. No regression function is explicitly fitted and the method has no neural weight parameters.

Settings and design choices

Specify direction, treatment of X ties, whether Y is assumed continuous, and asymptotic versus permutation calibration. SciPy’s default does not assume continuous Y, so its valid generalized calculation can differ slightly from the simplified displayed continuous formula even on continuous simulated data.

Fitting and adaptation

Re-sort and re-rank a new paired sample. For permutation inference under independence, randomize pairings and reproduce the same tie and sorting conventions. If both directions are screened, prespecify how their tests are combined or adjust for selection. No fine-tuning stage applies.

Sensitivity and robustness

Coarse discrete measurements, small samples, and particular smooth alternatives can yield limited power despite broad consistency results. Xi near one concerns functional dependence in one direction, not invertibility or causal influence. Arbitrary deterministic tie breaking without appropriate theory is not a complete inferential procedure.

How to use and calibrate

Use the upper normal tail asymptotically or the documented permutation/tie adjusted procedure.

Example application

Screen for functional but nonmonotonic dependence of Y on X.

Interpretation and pitfalls

Watch out

Xi is directional; exchanging X,Y changes it. Small sample power and ties require care, and arbitrary tie breaking is insufficient.

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

Xi is directional: xi(X,Y) need not equal xi(Y,X). Verify tie handling and null calibration before comparing implementations.

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=100);y=x*x+rng.normal(size=100)
print(stats.chatterjeexi(x,y))
Output
SignificanceResult(statistic=np.float64(0.26852685268526855), pvalue=np.float64(1.0938093851980508e-05))
R

Validated — Executed successfully in the validation environment · needs XICOR

set.seed(2026)
x<-rnorm(100);y<-x^2+rnorm(100)
print(XICOR::xicor(x,y,pvalue=TRUE))
Output
$xi
[1] 0.2634263

$sd
[1] 0.06325978

$pval
[1] 1.562236e-05

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 089, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT089.