This repository contains the code related to our final project for class 20592 Statistics and Probability at Bocconi University. The project aims at illustrating the use of Bayesian methods for estimating the coefficient of a probit regression model for binary outcomes. In particular, the code in this repository implements the Metropolis algorithm and the auxiliary variable Gibbs sampler and runs simulations to show how they can be used to estimate the coefficients of a probit regression model.
The current repository is structured as follows:
data/finney47.csv
: dataset used for testing the methods implemented inmetropolis.py
andgibbs.py
(TODO: add citation);images/
: contain trace plots and distribution plots obtained from the simulations ingibbs_simulation.py
andmetropolis_simulation.py
;project/
:base.py
: implements BaseBayesianProbit class;gibbs.py
: implements auxiliary variable Gibbs sampler inGibbsProbit
class;metropolis.py
: implements Metropolis algorithm inMetropolisProbit
class;utils.py
: implements utility functions for loading the data and obtaining the plots shown inimages
;
bayesian_probit.pdf
: final PDF report;gibbs_simulation.py
: main simulation script for testing the auxiliary variable Gibbs sampler;metropolis_simulation.py
: main simulation script for testing the Metropolis algorithm;README.md
;requirements.txt
.
The Python packages required to run the simulations can be installed from withing the repository by using the pip
package manager:
pip install -r requirements.txt
The simulations performed for the project can be replicated by running:
python gibbs_simulation.py
python metropolis_simulation.py
If not already present in images/
, new trace plots and distribution plots for the coefficients of the probit model sampled by the two methods mentioned above are generated and stored.
- Stefano Cortinovis
- Daniele Micheletti
- Andrea Teruzzi
- Leonardo Yang