BinomialPolya node
The BinomialPolya node implements a Binomial likelihood with a logistic linear predictor, augmented with a Pólya-Gamma auxiliary variable for tractable Bayesian inference:
\[y \mid x, \beta, n \sim \mathrm{Binomial}\!\left(n,\; \sigma(x^\top \beta)\right)\]
where σ is the logistic (sigmoid) function, x is a feature vector, β is a weight vector with a Normal prior, and n is the number of trials.
Interfaces
| Interface | Role |
|---|---|
y | Observed count (number of successes) |
x | Feature vector |
n | Number of trials |
β | Weight vector (Normal prior) |
The Pólya-Gamma augmentation trick
Combining a Normal prior on β with a Binomial likelihood through a logistic link is not conjugate — the posterior has no closed form. The Pólya-Gamma augmentation (Polson et al., 2013) introduces a latent variable ω ~ PG(n, x⊤β) such that, conditional on ω, the likelihood becomes Gaussian. This makes the full-conditional update for β analytically tractable and allows the engine to perform exact conjugate message passing instead of sampling or variational approximation.
This is useful for:
- Binomial regression — modeling count data with a logistic link.
- Binary classification — as a special case with
n = 1.
Meta and tuning
BinomialPolyaMeta controls the Monte Carlo estimation of the average energy:
| Field | Default | Effect |
|---|---|---|
n_samples | 1 | Number of samples for MC energy estimation. Increasing adds cost with diminishing accuracy benefit. |
rng | Random.default_rng() | Random number generator. |
If no meta is provided (meta = nothing), the rules use posterior means instead of sampling, which yields very similar results at no extra cost.
ReactiveMP.BinomialPolya — Type
BinomialPolyaA node type representing a Binomial likelihood with linear predictor through logistic. A Normal prior on the weights is used. The prior is augmented with a PolyaGamma distribution, which is used for modeling count data with overdispersion. This implementation follows the PolyaGamma augmentation scheme for Bayesian inference. Can be used for Binomial regression.
ReactiveMP.BinomialPolyaMeta — Type
BinomialPolyaMetaMetadata structure for the BinomialPolya node. It will be passed to rules. In case no meta is provided, the rules will use the means to compute the messages. Both schemes yield very similar results.
Fields
n_samples::Int: Number of samples to use for Monte Carlo estimation of the average energy. Default is 1, as increasing it adds computational cost without significant benefit.rng::AbstractRNG: Random number generator to use for sampling. Defaults to Random.default_rng().