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 | RSS feed

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.

Source Distribution

bayessynth-0.1.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

bayessynth-0.1-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file bayessynth-0.1.tar.gz.

File metadata

  • Download URL: bayessynth-0.1.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for bayessynth-0.1.tar.gz
Algorithm Hash digest
SHA256 22780bfedc76d8ba7f26f157ad8f26ac261eaa55ac7e6983bbcca246da691a99
MD5 03f2511c9d332cd2172940dee1637903
BLAKE2b-256 6ec02fc524a321f2ca13e2c107213c06063d65915aba14fa0028f2cc202ed346

See more details on using hashes here.

File details

Details for the file bayessynth-0.1-py3-none-any.whl.

File metadata

  • Download URL: bayessynth-0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for bayessynth-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f1a752346e55305533fe4cb3a22753f5721ab6a5dc011584adae7f5b2624a81
MD5 ff34f0affd6f91bb034115e0dc67241c
BLAKE2b-256 31c5b146f6a8a3a71e175689d9e83ab51c4e84d1a06172ed0bfe04f1c8932faf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page