Abstract
We propose two nonparametric statistical tests of goodness of fit for conditional distributions: given a conditional probability density function $p(y|x)$ and a joint sample, decide whether the sample is drawn from $p(y|x)p(x)$. Our tests, Kernel Conditional Stein Discrepancy (KCSD) and Finite Set Conditional Discrepancy (FSCD), leverage Stein operators and kernel methods to handle high-dimensional data and intractable normalizing constants.
Introduction
Evaluating conditional density models $p(y|x)$ is a cornerstone of machine learning and econometrics, yet it remains a significant challenge. Traditional "Goodness-of-Fit" (GoF) tests often struggle with three primary issues: the "Normalization Trap," where complex models lack a tractable normalizing constant; the "Curse of Dimensionality," which degrades the performance of classic tests like Kolmogorov-Smirnov; and the "Density Estimation Bottleneck," where intermediate density estimation introduces errors. This work introduces a framework to bypass these hurdles using Stein operators and kernel-based discrepancies.
Methodology
The core of our approach lies in the use of the Langevin Stein operator, which depends only on the score function $\nabla_y \log p(y|x)$. This property allows for testing models where the normalizing constant is unknown.
Kernel Conditional Stein Discrepancy (KCSD)
KCSD is a global test statistic that utilizes vector-valued Reproducing Kernel Hilbert Spaces (RKHS) to measure the discrepancy between the model and the data across the entire domain. It provides a robust, consistent measure of fit.
Finite Set Conditional Discrepancy (FSCD)
FSCD offers a more localized evaluation by testing the model at a small set of "test locations" in the covariate space. A significant innovation is the ability to optimize these locations by maximizing the test power, allowing the algorithm to automatically identify regions where the model fails most significantly.
Experimental Results
We evaluated KCSD and FSCD against synthetic benchmarks and real-world data.
Synthetic Benchmarks
We tested three scenarios:
- Linear Gaussian Model (LGM): Verified that the tests maintain the correct type-I error rate under the null hypothesis.
- Heteroscedastic Gaussian Model (HGM): Demonstrated sensitivity to localized errors. Optimized FSCD outperformed benchmarks by pinpointing specific regions of variance misalignment.
- Quadratic Gaussian Model (QGM): Showed KCSD's strength in detecting diffuse, global errors.
Real-World Application: NYC Taxi Data
Using over 5 million trip records, we tested a Mixture Density Network (MDN) modeling drop-off locations given pick-up locations. Our tests successfully identified specific pick-up locations where the neural network failed to capture the multimodality of the data, such as failing to distinguish between distinct popular destinations from a single origin.
Discussion and Conclusion
Our proposed tests provide a powerful, interpretable framework for conditional GoF testing. Unlike previous methods, KCSD is consistent without requiring bandwidth decay, and FSCD offers diagnostic capabilities by highlighting model failure points. While current implementations scale at $O(n^2)$, future work involving Random Fourier Features promises to reduce this to $O(n)$, making these tests applicable to even larger datasets.
Summary updated