"Computational Brain/Behavior Modeling (CBM)" Library for model fitting and model selection.
CBM provides a complete pipeline for fitting computational models to behavioral data and comparing competing models at the group level. The toolkit implements three core methods:
-
Individual-level fitting uses Laplace approximation to estimate maximum a posteriori (MAP) parameters for each subject, providing both parameter estimates and model evidence.
-
Bayesian Model Selection (BMS) implements random effects analysis to determine the frequency of different models in the population, accounting for between-subject variability.
-
Hierarchical Bayesian Inference (HBI) performs joint fitting and model comparison, pooling information across subjects and models to improve parameter estimation while simultaneously inferring model frequencies.
The library is designed for cognitive modeling applications where multiple computational models are fit to data from multiple subjects, and researchers need to determine which model best explains the data at the group level.
- Individual Fitting: Maximum a posteriori (MAP) estimation with Laplace approximation
- Bayesian Model Selection: Random effects model selection with exceedance probabilities
- Hierarchical Bayesian Inference: Group-level inference across subjects and models
git clone https://github.com/payampiray/cbm_python.git
cd cbm_python
pip install -e .examples/exampla_individual_fit.py: Minimal individual fitexamples/example_model_selection.py: BMS with linear modelsexamples/example.py: HBI with linear modelsexamples/example_RL.py: Individual fit and HBI with RL vs RL2 (dual learning rates)
Outputs are written to examples/output/.
- Python >= 3.9
- Dependencies: NumPy, SciPy, Pickle
- Logs and pickle outputs are stored under
examples/output/
-
cbm_power: CBM library for power analysis and sample-size optimization for computational studies.
-
A MATLAB implementation of CBM: github.com/payampiray/cbm.
If you use this package, please cite the following paper:
- Piray et al., "Hierarchical Bayesian inference for concurrent model fitting and comparison for group studies", PLoS Computational Biology, 2019.