Abstract
This paper presents a detailed derivation and implementation of variational Bayesian (VB) inference for linear and logistic regression models. By incorporating Automatic Relevance Determination (ARD), these models facilitate automated feature selection and robust model comparison without the computational burden of Markov Chain Monte Carlo (MCMC) methods. We provide a tutorial-style overview of the mathematical framework and demonstrate the efficacy of the approach using synthetic high-dimensional datasets.
Introduction
In statistical modeling, linear and logistic regression are fundamental tools. While Bayesian formulations of these models allow for uncertainty quantification and the integration of prior knowledge, hierarchical structures often lead to intractable posterior distributions. Traditionally, researchers have relied on MCMC methods to approximate these posteriors. However, MCMC's computational cost often limits its applicability in large-scale or real-time scenarios.
Variational Bayesian (VB) inference offers a deterministic alternative by approximating the true posterior with a simpler, factorized distribution. Despite its advantages, accessible step-by-step derivations for standard regression models are often missing from the literature. This work bridges that gap, providing both the theoretical foundation and a practical MATLAB/Octave implementation.
Methodology
The core of the proposed framework involves two distinct regression models, both enhanced by Automatic Relevance Determination (ARD).
Linear Regression
For linear regression, the model employs a normal inverse-gamma prior for the regression coefficients and the noise variance. This choice of conjugate prior ensures that the variational updates remain analytically tractable, allowing for efficient iterative estimation of the posterior parameters.
Logistic Regression
Logistic regression presents a greater challenge because the sigmoid link function is not conjugate to a Gaussian prior. To maintain the variational framework, we utilize the Jaakkola-Jordan local variational bound. This method introduces an additional variational parameter to create a quadratic lower bound on the log-likelihood, enabling a Gaussian approximation of the posterior.
Automatic Relevance Determination (ARD)
The "Automatic Relevance Determination" variant assigns an individual hyper-prior to each regression coefficient. During the optimization of the variational lower bound, the model identifies uninformative features by driving their associated weights toward zero. This mechanism effectively performs feature selection within the Bayesian framework, eliminating the need for external cross-validation or manual parameter tuning.
Model Selection and the Variational Bound
A significant advantage of the VB approach is the calculation of the variational lower bound ($\mathcal{L}(Q)$). This value acts as a proxy for the model evidence. In practice, $\mathcal{L}(Q)$ can be used to compare different model architectures—such as determining the optimal degree of a polynomial—directly from the training data. This provides a principled way to avoid overfitting while maintaining model complexity where necessary.
Empirical Results
The effectiveness of the VB and ARD implementations was evaluated using synthetic datasets designed to simulate challenging high-dimensional and sparse environments.
High-Dimensional Performance
In tests involving 100 features and 150 observations, the VB approach demonstrated superior generalization compared to Maximum Likelihood Estimation (MLE). While MLE tended to overfit by capturing noise, the VB model achieved a Test Mean Squared Error (MSE) of 3.22, compared to 3.62 for MLE.
Sparsity and Feature Selection
The ARD implementation was tested on a 1000-dimensional problem where only 10% of the features were informative. The results were stark:
- VB with ARD: Test MSE of 3.23
- Standard VB: Test MSE of 7.16
- MLE: Test MSE of 277.11
The ARD variant successfully suppressed the 900 irrelevant dimensions, maintaining high predictive accuracy where other methods failed due to the "curse of dimensionality."
Discussion and Limitations
While VB inference provides significant speed and feature selection benefits, it is not without limitations.
- Numerical Stability: The logistic regression implementation requires matrix inversions that can become unstable if features are highly correlated (ill-conditioned data).
- Approximation Bias: VB is known to be "over-confident," typically underestimating the variance of the posterior distribution relative to the true distribution found via MCMC.
- Prior Sensitivity: Although the framework uses relatively uninformative priors, the choice of hyper-parameters can still influence the model's initial shrinkage behavior, particularly in low-data regimes.
Conclusion
Variational Bayesian inference for linear and logistic regression provides a robust, efficient alternative to traditional MCMC and MLE methods. By leveraging ARD and the variational lower bound, practitioners can perform automated feature selection and model comparison within a unified probabilistic framework. The accompanying VBLinLogit library provides a ready-to-use implementation for the research community.
Summary updated