Skip to main content

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.

Metadata

Release files for bayessynth 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bayessynth 0.1
File Size Uploaded Provenance
bayessynth-0.1.tar.gz 11.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bayessynth 0.1
File Interpreter ABI Platform
bayessynth-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 31.6 kB

Release files / bayessynth-0.1.tar.gz

Download URL bayessynth-0.1.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
22780bfedc76d8ba7f26f157ad8f26ac261eaa55ac7e6983bbcca246da691a99
BLAKE2b-256 checksum
How to use checksums
6ec02fc524a321f2ca13e2c107213c06063d65915aba14fa0028f2cc202ed346
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / bayessynth-0.1-py3-none-any.whl

Download URL bayessynth-0.1-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f1a752346e55305533fe4cb3a22753f5721ab6a5dc011584adae7f5b2624a81
BLAKE2b-256 checksum
How to use checksums
31c5b146f6a8a3a71e175689d9e83ab51c4e84d1a06172ed0bfe04f1c8932faf
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for bayessynth 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page