Evaluation, diagnostics, benchmarks, and additional tests · Evaluation, diagnostics, benchmarks, and additional hypothesis tests · EVA007 · Hypothesis test
Selective inference after hierarchical clustering
Tests differences between selected clusters while accounting for the fact that the same data selected those clusters.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page. The methods that run it are Experimental.
Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.
- Availability
- Runs in CodeSplash (Experimental)
- Code example
- Complete calculation
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through discover.cluster_inference. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Tests differences between selected clusters while accounting for the fact that the same data selected those clusters.
Question / hypotheses
Typically H0: selected population-mean contrasts are zero, conditional on a specified clustering selection event under a Gaussian model.
Architecture / computational structure
Compute the norm of the selected cluster-mean contrast. Condition on the selected groups and the nuisance projections/direction specified by the method; determine which perturbed datasets preserve that selection. The null reference is then a scaled chi distribution restricted to the resulting set, which can contain multiple intervals.
Assumptions
Validity depends on the model, linkage/selection event, variance treatment, and exact conditioning scheme. Arbitrary embeddings followed by ordinary t tests do not inherit selective validity.
Formula / computational definition
Parameters and notation
T is the norm of a selected mean-contrast vector; under the spherical Gaussian model its unselected reference is a scaled chi distribution with q feature dimensions. S defines the computed selection set. Selected groups and linkage are algorithmic choices; covariance or noise scale require the treatment justified by the theorem.
Fitting, fine-tuning, and adaptation
Fine-tuning is inapplicable. Linkage, the tested pair, covariance treatment, and any preprocessing must match the selection calculation. Changing the hierarchy or pair requires recomputing the event and conditional tail. The snippet evaluates a supplied single-interval chi tail only; it does not derive the event from a dendrogram.
How to use and calibrate
Use an implementation matching the published selection scheme. Record the full clustering pipeline and selection rule; compare the conditional interval with the naive interval only as an illustration of selection bias.
Example application
Test whether two clusters selected from the same measurements differ beyond what the clustering operation alone would induce.
Interpretation / pitfalls
Watch out
A generic truncation is not the full hierarchical-clustering method. Sample splitting does not automatically fix every post-clustering estimand, especially if test-set cluster assignments themselves use the features being tested.
Python and R code examples
Scope: Mathematical calculation on synthetic inputs; not a complete benchmark pipeline.
Validation: Python — Executed successfully on synthetic inputs. R — reviewed but not executed in this environment. Python dependencies are explicit imports; R uses base R unless a package/bridge is explicitly named.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Complete calculation — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline. · needs scipy
from scipy.stats import chi
t=2.5; lower=1.5; q=2
print(chi.sf(t,df=q)/chi.sf(lower,df=q))
# Standardized chi-q radius with a supplied selection set [lower,infinity).
# Does not derive the selection set or run hierarchical-clustering inference.
Complete calculation — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline.
t <- 2.5; lower <- 1.5; q <- 2
print(pchisq(t^2,df=q,lower.tail=FALSE)/pchisq(lower^2,df=q,lower.tail=FALSE))
# Standardized chi-q radius; supplied truncation interval, not the full procedure.
Sources
- Source 1pmc.ncbi.nlm.nih.gov
- Source 2github.com
From the CodeSplash reference, entry EVA007.