cyclicmodel
Statistical causal discovery based on cyclic model.
This project is under development.
Summary
Python package that performs statistical causal discovery under the following condition:
- there are unobserved common factors
- two-way causal relationship exists
cyclicmodel has been developed based on
bmlingam, which implemented bayesian mixed LiNGAM.
Example
import numpy as np
import pymc3 as pm
import cyclicmodel as cym
# Generate synthetic data,
# which assumes causal relation from x1 to x2
n = 200
x1 = np.random.randn(n)
x2 = x1 + np.random.uniform(low=-0.5, high=0.5, size=n)
xs = np.vstack([x1, x2]).T
# Model settings
hyper_params = cym.define_model.CyclicModelParams(
dist_std_noise='log_normal',
df_indvdl=8.0,
dist_l_cov_21='uniform, -0.9, 0.9',
dist_scale_indvdl='uniform, 0.1, 1.0',
dist_beta_noise='uniform, 0.5, 6.0')
# Generate PyMC3 model
model = cym.define_model.get_pm3_model(xs, hyper_params, verbose=10)
# Run variational inference with PyMC3
with model:
fit = pm.FullRankADVI().fit(n=100000)
trace = fit.sample(1000, include_transformed=True)
# Check the posterior mean of the coefficients
print(np.mean(trace['b_21'])) # from x1 to x2
print(np.mean(trace['b_12'])) # from x2 to x1
Installation
pip install cyclicmodel
References
- LiNGAM - Discovery of non-gaussian linear causal models
- Shimizu, S., & Bollen, K. (2014). Bayesian estimation of causal direction in acyclic structural equation models with individual-specific confounder variables and non-Gaussian distributions. Journal of Machine Learning Research, 15(1), 2629-2652.
Release files for cyclicmodel 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cyclicmodel-0.0.4.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cyclicmodel-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.9 kB
Release files / cyclicmodel-0.0.4.tar.gz
| Download URL | cyclicmodel-0.0.4.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98a7c74e285fb7050e27ea29151f02e7a2e5d18c6a30358bb3639395f170237e
|
|
BLAKE2b-256 checksum How to use checksums |
d16fa581c5effe5598ac2ba04ff889867f7340903734a580d2876204ecc0d8a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / cyclicmodel-0.0.4-py3-none-any.whl
| Download URL | cyclicmodel-0.0.4-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9009ad8e98e2bea3968886e607a30df28e24346ed45f5b3a91b3d95034a9b5c
|
|
BLAKE2b-256 checksum How to use checksums |
4286d7ab4925b36320c602b97057b4b39aaaa81a08cea8d31dfce1623a442b0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |