Skip to main content

Python implementation of Bayesian Synthetic Controls

Project description

bayessynth: BSC Models in Python

The bayessynth package is a Python implementation of the Bayesian Synthetic Control (BSC). BSC is a probabilistic method for quantitative social science, developed in Tuomaala (2019)[1]. It includes tools to estimate the BSC model with Markov Chain Monte Carlo (MCMC) sampling and to analyze and visualize the results.

Documentation

Limited documentation for the library is available separately within this git repository.

Dependencies

Fitting of the BSC model is done using pymc3, which itself uses depends on theano and scipy. Other fundamental dependencies include numpy, pandas, and sklearn, as well as the visualization libraries matplotlib and seaborn.

Author

Elias Tuomaala

Website: www.eliastuomaala.com

Email: mail@eliastuomaala.com

License

The bayessynth copyright belongs to Elias Tuomaala (2020). It is released under the MIT License.

Example

import numpy as np
import pandas as pd
import bayessynth as bs

data_source, target_country, cutoff_year = 'gdp.csv', 'DEU', 1990
factors = 4
prior_distribution = {
                      'sigma_gamma': 500,
                      'k_mu': 16000,
                      'k_sd': 7000,
                      'k_gamma': 7000,
                      'alpha_sd': 30000,
                      'alpha_mu': 0,
                      'b_mu': 0,
                      'b_sd': 1,
                      'b_gamma': 1,
                      'delta_mu': 0,
                      'delta_sd': 10000
}
data = pd.read_csv(data_source)

bs.fit(data, target_country, cutoff_year, prior_distribution)
trace = bs.read_tracefile(target, data, factors)
result_summary = bs.summarize_ppc(target_country, data, trace, factors)
bs.plot(result_summary, cutoff_year, target_country, output='display')

[1]: Elias Tuomaala. (2019) "The Bayesian Synthetic Control: Improved Counterfactual Estimation in the Social Sciences through Probabilistic Modeling." Arxiv Open Access.

Project details


Release history Release notifications

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for bayessynth, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size bayessynth-0.1-py3-none-any.whl (19.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size bayessynth-0.1.tar.gz (11.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page