Fits a generalized linear model with a Gaussian coefficient prior by Expectation Propagation: the posterior is approximated by a Gaussian whose per-observation sites match the moments of the tilted distribution (via Gauss-Hermite quadrature). EP is exact for a Gaussian likelihood and typically more accurate than Laplace on skewed likelihoods, since it matches marginal moments rather than the mode curvature.
Usage
tulpa_ep(
formula,
data,
family = "binomial",
phi = 1,
phi2 = NULL,
n_trials = NULL,
beta_prior = .tulpa_default_beta_prior("ep"),
control = list()
)Arguments
- formula
Model formula.
- data
A data frame.
- family
Character family name (see
family_names()).- phi
Dispersion passed to the family, held fixed. One convention at every door: for
gaussian/lognormalthis is the residual VARIANCE (the SD issqrt(phi)), forneg_binomial_2the size,gammathe shape,betathe precision,tthe scale;binomialandpoissonignore it. The compiled kernels parameterize the two variance families by the residual SD and are handedsqrt(phi)at the boundary.- phi2
Optional second dispersion (Student-t degrees of freedom for
family = "t"; default 4 whenNULL).- n_trials
Binomial denominators (length
nrow(data)), orNULL(= 1).- beta_prior
Fixed-effect prior as
list(mean, sd): a mean-zero (mean = 0) Gaussian on every coefficient with SDsd(default the engine default,prior_normal(0, 2.5)). EP's site parameterisation assumes a mean-zero coefficient prior, so a non-zeromeanerrors – use a sampler (mode = "mala") for a shifted prior.- control
List:
max_sweeps(default 50),tol(default 1e-6),damping(default 0.8),n_quad(Gauss-Hermite nodes, default 20),n_draws(default 2000),seed.
Value
A tulpa_fit (subclass tulpa_ep) with coefficients (posterior
mean), vcov, draws, log_marginal (the EP approximation), converged.
References
Minka (2001). Expectation Propagation for approximate Bayesian inference. UAI. Rasmussen & Williams (2006). Gaussian Processes for Machine Learning, Algorithm 3.5.
See also
tulpa() (Laplace / sampler tiers), pathfinder() (VI).