A kernel Stein test for comparing latent variable models

Heishiro Kanagawa, Wittawat Jitkrittum, Lester Mackey, Kenji Fukumizu, Arthur Gretton

Abstract

Evaluating the relative fit of Latent Variable Models (LVMs) is a fundamental challenge in statistics, often hindered by the intractability of marginalizing hidden variables. We present a new frequentist test based on the Latent Kernel Stein Discrepancy (LKSD). By combining Stein’s method with Fisher’s Identity and MCMC sampling, this approach enables model comparison without requiring tractable marginal likelihoods or normalizing constants. Experimental results across Probabilistic PCA, Dirichlet Process Mixtures, and Latent Dirichlet Allocation demonstrate that the LKSD test significantly outperforms standard black-box methods like the Maximum Mean Discrepancy (MMD) test in both power and sensitivity to latent structures.

Introduction

Latent Variable Models (LVMs)—including Topic Models, Hidden Markov Models, and Probabilistic PCA—are essential tools for capturing the unobserved factors driving complex datasets. Despite their ubiquity, comparing two competing LVMs to determine which better represents a given dataset remains a significant hurdle.

The primary obstacle is the "intractability trap." Calculating a model's fit typically requires the marginal distribution, which involves integrating over all possible states of the hidden variables. For most modern, high-dimensional models, these integrals are mathematically impossible to solve exactly. Consequently, standard likelihood-ratio tests are often inapplicable. While researchers frequently turn to "two-sample tests" like the Maximum Mean Discrepancy (MMD), which compare samples from the model to real data, these methods treat the model as a black box and ignore the rich structural information encoded within the model’s parameters.

The Latent Kernel Stein Discrepancy (LKSD)

To address these limitations, we propose the Latent Kernel Stein Discrepancy (LKSD) test. This method leverages the model's internal structure to provide a more sensitive measure of fit. The framework rests on three technical pillars:

1. Stein’s Method and the Score Function

Instead of calculating probability densities directly, the test utilizes a Stein operator. This operator characterizes a distribution by ensuring that the expectation of specific functions under that distribution is zero. A key component of this operator is the "score function"—the gradient of the log-density.

2. Bridging the Intractability with Fisher’s Identity

In LVMs, the score function of the marginal distribution is usually intractable. We circumvent this by applying Fisher’s Identity, which expresses the marginal score as the posterior expectation of the conditional score. This shift is crucial: while we cannot compute the marginal score directly, we can often compute the conditional score and approximate the posterior expectation.

3. MCMC-Based Estimation

Since the posterior itself is often intractable, we employ Markov Chain Monte Carlo (MCMC) to approximate the required expectations. While MCMC introduces sampling bias, we demonstrate that this bias decays at a rate of $O(1/m)$ (where $m$ is the number of MCMC steps). Because this is faster than the $O(1/\sqrt{n})$ statistical fluctuations of the test itself, the LKSD remains a valid frequentist test even with approximate samples. To control the Type-I error rate, we utilize a jackknife variance estimator for the resulting U-statistic.

Experimental Evaluation

The LKSD test was evaluated against the MMD test across several synthetic and real-world scenarios:

  • Probabilistic PCA (PPCA): In this continuous-variable setting where marginals are tractable, LKSD reached a 100% detection rate (power) significantly faster than MMD as the sample size increased.
  • Latent Dirichlet Allocation (LDA):
    • Synthetic Sparsity: The test was used to distinguish between models with different sparsity priors. LKSD successfully identified the correct model, whereas MMD exhibited almost zero power, failing to detect the subtle differences in topic distributions.
  • Real-World arXiv Data: We compared models trained on different categories of research abstracts (e.g., "Statistics Theory" vs. "Probability"). LKSD correctly identified the "Statistical Methodology" model as the superior fit for "Statistics Theory" papers, outperforming sample-based alternatives.
  • Discrete Domains: The framework was extended to discrete data by replacing gradients with cyclic differences, proving the versatility of the Stein approach across different data types.

Discussion and Future Work

The LKSD test offers a powerful alternative to black-box sampling methods by exploiting the score function of the model. It is particularly valuable for unnormalized models where normalizing constants are unknown.

However, the method is not without limitations. Its performance is intrinsically linked to the mixing properties of the MCMC sampler; slow convergence can lead to biased results. Additionally, in discrete models, the score function involves reciprocals of probabilities, which can lead to numerical instability if the model assigns near-zero probability to observed data points. Future research will focus on refining "stable" versions of the test and addressing degenerate cases where two models are nearly identical, potentially through the use of sample-splitting techniques.

Summary updated

BibTeX
@misc{kanagawa2019kernel,
  author = {Heishiro Kanagawa and Wittawat Jitkrittum and Lester Mackey and Kenji Fukumizu and Arthur Gretton},
  title = {{A kernel Stein test for comparing latent variable models}},
  year = {2019},
  eprint = {1907.00586},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1907.00586},
}
Figure