CAssociation · Guide test 089
Chatterjee xi independence test
Uses rank based xi to test independence, including nonmonotonic dependence under appropriate conditions.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Test for any dependence (ξ, Hoeffding, distance correlation, HSIC) — Are two variables related in any way, linear or not?
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
Shape of the link
Your data
Simulated with a known linkIf H₀ were true
- The reference: how z 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 = .045).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- ranks of y after sorting by x
- number of y values at least y_i
- 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 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
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.
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))
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
- SciPy — SciPy · chatterjeexidocs.scipy.org
- scipy.stats.chatterjeexidocs.scipy.org
- xicorsearch.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 089, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT089.