pyro-ppl / brmp

Bayesian Regression Models in Pyro
Apache License 2.0
69 stars 8 forks source link

Bayesian Regression Models

This is an attempt to implement a brms-like library in Python.

It allows Bayesian regression models to be specified using (a subset of) the lme4 syntax. Given such a description and a pandas data frame, the library generates model code and design matrices, targeting either Pyro or NumPyro.

Resources

Current Status

Model Specification

Formula

Here are some example formulae that the system can handle:

Formula Description
y ~ x Population-level effects
y ~ 1 + x
y ~ x1:x2 Interaction between variables
y ~ 1 + x0 + (x1 \| z) Group-level effects
y ~ 1 + x0 + (1 + x1 \| z)
y ~ 1 + x0 + (1 + x1 \|\| z) No correlation between group coefficients
y ~ 1 + x0 + (1 + x1 \| z1:z2) Grouping by multiple factors (untested)
y ~ 1 + x0 + (x1 \| z0) + (1 + x2 \|\| z1) Combinations of the above

Priors

Custom priors can be specified at various levels of granularity. For example, users can specify:

Users can give multiple such specifications and they combine in a sensible way.

Response Families

The library supports models with either (uni-variate) Gaussian or Binomial (inc. Bernoulli) distributed responses.

Inference

The Pyro back end supports both NUTS and SVI for inference. The NumPyro backend supports only NUTS.

The library includes the following functions for working with posteriors:

Limitations