BAyesian Model-Building Interface (Bambi) in Python¶
Bambi is a high-level Bayesian model-building interface written in Python. It works with the probabilistic programming frameworks PyMC3 and is designed to make it extremely easy to fit Bayesian mixed-effects models common in biology, social sciences and other disciplines.
Dependencies¶
Bambi is tested on Python 3.7+ and depends on ArviZ, formulae, NumPy, pandas, PyMC3 and statsmodels (see requirements.txt for version information).
Installation¶
The latest release of Bambi can be installed using pip:
pip install bambi
Alternatively, if you want the bleeding edge version of the package, you can install from GitHub:
pip install git+https://github.com/bambinos/bambi.git
Usage¶
A simple fixed effects model is shown below as example.
from bambi import Model
import pandas as pd
# Read in a tab-delimited file containing our data
data = pd.read_table('my_data.txt', sep='\t')
# Initialize the fixed effects only model
model = Model('DV ~ IV1 + IV2', data)
# Fit the model using 1000 on each of 4 chains
results = model.fit(draws=1000, chains=4)
# Use ArviZ to plot the results
az.plot_trace(results)
# Key summary and diagnostic info on the model parameters
az.summary(results)
# Drop the first 100 draws (burn-in)
results_bi = results.sel(draw=slice(100, None))
For a more in-depth introduction to Bambi see our Quickstart or our set of example notebooks.
Citation¶
If you use Bambi and want to cite it please use
Here is the citation in BibTeX format
@misc{capretto2020,
title={Bambi: A simple interface for fitting Bayesian linear models in Python},
author={Tomás Capretto and Camen Piho and Ravin Kumar and Jacob Westfall and Tal Yarkoni and Osvaldo A. Martin},
year={2020},
eprint={2012.10754},
archivePrefix={arXiv},
primaryClass={stat.CO}
}
Contributing¶
We welcome contributions from interested individuals or groups! For information about contributing to Bambi, check out our instructions, policies, and guidelines here.
Contributors¶
See the GitHub contributor page.
Contents¶
- Getting Started
- Examples
- T-test
- Multiple Regression
- Posterior Predictive
- Logistic Regression
- Model assessment
- Multi-level Regression
- Bayesian Workflow (Strack RRR Analysis Replication)
- Wald and Gamma Regression (Australian insurance claims 2004-2005)
- Negative Binomial Regression
- Binary response: Alternative link functions
- Logistic Regression and Model Comparison with Bambi and ArviZ
- API Reference