Crate polya_gamma

Crate polya_gamma 

Source
Expand description

§Polya-Gamma Sampler and Bayesian Logistic Regression

This crate provides an efficient sampler for Polya-Gamma (PG) random variates, along with a Gibbs sampler for Bayesian logistic regression using PG data augmentation.

§Features

  • Polya-Gamma Sampler:

    • Draws samples from the PG(b, c) distribution using different strategies depending on the value of b.
    • High-performance, high-accuracy sampling.
  • Bayesian Regression:

    • Implements Gibbs samplers using PG augmentation for fully-conjugate updates of regression coefficients.
    • For logistic regression, see [regression::GibbsLogit].
    • For negative binomial regression (count data), see [regression::GibbsNegativeBinomial].
    • These are available under the regression feature flag.

§Mathematical Background

The Polya-Gamma distribution PG(b, c) is used for data augmentation in models with logistic link functions, enabling efficient Bayesian inference. See:

  • Polson, N.G., Scott, J.G., & Windle, J. (2013). Bayesian Inference for Logistic Models Using Polya-Gamma Latent Variables. JASA, 108(504): 1339–1349.
  • Windle, J., Polson, N.G., & Scott, J.G. (2014). Sampling Pólya-Gamma random variates: alternate and approximate techniques. arXiv:1405.0506.

§Usage Example

use polya_gamma::PolyaGamma;
let pg = PolyaGamma::new(1.0);
let sample = pg.draw(&mut StdRng::seed_from_u64(0), 1.0);

For examples of Bayesian regression models, see the documentation for the [regression] module and the specific model structs like [regression::GibbsLogit]. The examples directory in the repository also contains runnable examples.

§License

This crate is dual-licensed under the MIT OR Apache-2.0 licenses. See LICENSE-MIT and LICENSE-APACHE for details.

Structs§

PolyaGamma
Polya-Gamma sampler.