Selective inference after cross-validation

Joshua R. LoftusarXiv 2015 · DOI

Abstract

This paper describes a method for performing inference on models chosen by cross-validation. When the test error being minimized in cross-validation is a residual sum of squares it can be written as a quadratic form. This allows us to apply the inference framework in Loftus et al. (2015) for models determined by quadratic constraints to the model that minimizes CV test error. Our only requirement on the model training procedure is that its selection events are regions satisfying linear or quadratic constraints. This includes both Lasso and forward stepwise, which serve as our main examples throughout. We do not require knowledge of the error variance $\sigma^2$. The procedures described here are computationally intensive methods of selecting models adaptively and performing inference for the selected model. Implementations are available in an R package.

Introduction

In modern statistical practice, model selection is rarely a one-step process. Researchers frequently employ data-driven techniques like the Lasso or forward stepwise regression to identify relevant predictors. Crucially, cross-validation (CV) is almost universally used to determine the optimal level of model complexity—such as the number of steps or the penalty parameter $\lambda$.

However, this adaptive selection introduces a significant challenge: "data snooping." Standard statistical tests assume that the model structure was fixed before the data was observed. When the same data is used both to select the model and to test the significance of its components, the resulting p-values are biased. They tend to be overly optimistic, leading to an inflated rate of false positives. This paper addresses this gap by providing a rigorous framework for valid post-selection inference after cross-validation.

Methods: The Quadratic Constraint Framework

The core innovation of this work is the characterization of cross-validation selection events as a series of quadratic constraints on the data vector $y$.

CV as a Quadratic Form

When using the Residual Sum of Squares (RSS) as the error metric in K-fold cross-validation, the selection of the "best" model complexity involves comparing test errors across different candidate models. The author demonstrates that these comparisons are essentially comparisons of quadratic forms. Specifically, for each fold, the training and testing process generates linear and quadratic constraints. By reordering observations and using permutation matrices, the entire CV process—selecting the model that minimizes total test error—can be described as the intersection of these quadratic regions ($y^T Q y + a^T y + b \ge 0$).

Conditioning for Valid Inference

To obtain "honest" p-values, the method conditions the test statistic on the selection event. It asks: "Given that the data fell into the specific region that led cross-validation to choose this model, what is the probability of observing a result this extreme?" This conditioning effectively truncates the null distribution of the test statistic, removing the selection bias. This approach is applicable to any procedure where selection events are linear or quadratic, most notably the Lasso and Forward Stepwise Regression.

Results and Evaluation

The method was validated using synthetic Gaussian datasets to assess both Type 1 error control and statistical power.

Type 1 Error Control

In a "global null" simulation ($n=50, p=100$) where no variables have a true effect, valid p-values should follow a Uniform[0, 1] distribution. As shown in Figure 1, the empirical Cumulative Distribution Function (CDF) of the calculated p-values closely follows the 45-degree diagonal across multiple selection steps. This confirms that the method successfully controls the false positive rate even after adaptive model selection.

Figure 1: P-value distribution under the global null for different selection steps. The diagonal alignment indicates valid Type 1 error control.

Statistical Power

The method's ability to detect true effects was tested in a scenario with five non-zero coefficients. Figure 2 illustrates the contrast between null and non-null variables. The p-values for the truly important variables (Null = FALSE) are heavily skewed toward zero, indicating high statistical power. Meanwhile, the p-values for the null variables (Null = TRUE) remain uniform, demonstrating that the method maintains error control while still being sensitive to real signals.

Figure 2: Comparison of p-value distributions for null and non-null variables. The curve for non-null variables shows high power, while the null variables follow the uniform diagonal.

Discussion and Limitations

While this framework provides a mathematically sound solution to post-selection inference, it is computationally intensive. Solving for the intersections of high-dimensional quadratic regions is significantly more demanding than the linear constraints used in simpler selective inference cases. Future work may focus on geometric simplifications—for instance, identifying cases where quadratic constraints reduce to polyhedral ones—to improve algorithmic efficiency.

Furthermore, the utility of selective inference depends on the quality of the selection procedure. If the model selection process is fundamentally flawed for a given dataset, the resulting inference, while mathematically valid for the chosen model, may not provide meaningful insights into the underlying physical phenomenon.

The implementation of these methods is available in the selectiveInference R package, bridging the gap between theoretical statistics and practical data analysis.

Summary updated

BibTeX
@misc{loftus2015selective,
  author = {Joshua R. Loftus},
  title = {{Selective inference after cross-validation}},
  year = {2015},
  eprint = {1511.08866},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1511.08866},
}
Figure