{"id":16391685,"url":"https://github.com/inoueakimitsu/cyclicmodel","last_synced_at":"2026-01-24T04:07:21.914Z","repository":{"id":62566172,"uuid":"137284534","full_name":"inoueakimitsu/cyclicmodel","owner":"inoueakimitsu","description":"Statistical causal discovery based on cyclic model","archived":false,"fork":false,"pushed_at":"2018-06-14T13:27:51.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T09:13:57.572Z","etag":null,"topics":["causal-inference","data-science","probabilistic-programming","pymc3","statistics"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inoueakimitsu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-14T00:06:19.000Z","updated_at":"2020-09-27T22:42:51.000Z","dependencies_parsed_at":"2022-11-03T16:15:25.888Z","dependency_job_id":null,"html_url":"https://github.com/inoueakimitsu/cyclicmodel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inoueakimitsu%2Fcyclicmodel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inoueakimitsu%2Fcyclicmodel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inoueakimitsu%2Fcyclicmodel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inoueakimitsu%2Fcyclicmodel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inoueakimitsu","download_url":"https://codeload.github.com/inoueakimitsu/cyclicmodel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252847519,"owners_count":21813458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["causal-inference","data-science","probabilistic-programming","pymc3","statistics"],"created_at":"2024-10-11T04:47:02.535Z","updated_at":"2026-01-24T04:07:21.871Z","avatar_url":"https://github.com/inoueakimitsu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cyclicmodel\n\n[![CircleCI](https://circleci.com/gh/inoueakimitsu/cyclicmodel/tree/master.svg?style=svg)](https://circleci.com/gh/inoueakimitsu/cyclicmodel/tree/master)\n\n\nStatistical causal discovery based on cyclic model.  \nThis project is under development.\n\n## Summary\nPython package that performs statistical causal discovery\nunder the following condition:\n1. there are unobserved common factors\n2. two-way causal relationship exists\n\n`cyclicmodel` has been developed based on\n[`bmlingam`][4670f282], which implemented bayesian mixed LiNGAM.\n\n  [4670f282]: https://github.com/taku-y/bmlingam \"bmlingam\"\n\n## Example\n```Python\nimport numpy as np\nimport pymc3 as pm\nimport cyclicmodel as cym\n\n# Generate synthetic data,\n# which assumes causal relation from x1 to x2\nn = 200\nx1 = np.random.randn(n)\nx2 = x1 + np.random.uniform(low=-0.5, high=0.5, size=n)\nxs = np.vstack([x1, x2]).T\n\n# Model settings\nhyper_params = cym.define_model.CyclicModelParams(\n    dist_std_noise='log_normal',\n    df_indvdl=8.0,\n    dist_l_cov_21='uniform, -0.9, 0.9',\n    dist_scale_indvdl='uniform, 0.1, 1.0',\n    dist_beta_noise='uniform, 0.5, 6.0')\n\n# Generate PyMC3 model\nmodel = cym.define_model.get_pm3_model(xs, hyper_params, verbose=10)\n\n# Run variational inference with PyMC3\nwith model:\n  fit = pm.FullRankADVI().fit(n=100000)\n  trace = fit.sample(1000, include_transformed=True)\n\n# Check the posterior mean of the coefficients\nprint(np.mean(trace['b_21']))  # from x1 to x2\nprint(np.mean(trace['b_12']))  # from x2 to x1\n```\n\n## Installation\n```bash\npip install cyclicmodel\n```\n\n## References\n-  [LiNGAM - Discovery of non-gaussian linear causal models](https://sites.google.com/site/sshimizu06/lingam)\n- [Shimizu, S., \u0026 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.](http://jmlr.org/papers/volume15/shimizu14a/shimizu14a.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finoueakimitsu%2Fcyclicmodel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finoueakimitsu%2Fcyclicmodel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finoueakimitsu%2Fcyclicmodel/lists"}