{"id":32204606,"url":"https://github.com/darkeyes/bicausality","last_synced_at":"2025-10-22T04:59:31.204Z","repository":{"id":62459191,"uuid":"280107412","full_name":"DarkEyes/BiCausality","owner":"DarkEyes","description":"A framework to infer causality on binary data using techniques in frequent pattern mining and estimation statistics. Given a set of individual vectors S={x} where x(i) is a realization value of binary variable i, the framework infers empirical causal relations of binary variables i,j from S in a form of causal graph G=(V,E).","archived":false,"fork":false,"pushed_at":"2023-11-28T03:51:47.000Z","size":64330,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T04:59:22.602Z","etag":null,"topics":["binary-variable","causal-inference","estimation-statistics","exploratory-data-analysis","frequent-pattern-mining"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DarkEyes.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-07-16T09:09:04.000Z","updated_at":"2022-06-16T05:21:37.000Z","dependencies_parsed_at":"2023-11-28T04:48:39.194Z","dependency_job_id":null,"html_url":"https://github.com/DarkEyes/BiCausality","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DarkEyes/BiCausality","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkEyes%2FBiCausality","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkEyes%2FBiCausality/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkEyes%2FBiCausality/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkEyes%2FBiCausality/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DarkEyes","download_url":"https://codeload.github.com/DarkEyes/BiCausality/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkEyes%2FBiCausality/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280382997,"owners_count":26321423,"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","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["binary-variable","causal-inference","estimation-statistics","exploratory-data-analysis","frequent-pattern-mining"],"created_at":"2025-10-22T04:59:30.142Z","updated_at":"2025-10-22T04:59:31.196Z","avatar_url":"https://github.com/DarkEyes.png","language":"R","readme":"BiCausality: Binary Causality Inference Framework\n===========================================================\n[![minimal R version](https://img.shields.io/badge/R%3E%3D-3.5.0-6666ff.svg)](https://cran.r-project.org/)\n[![CRAN Status Badge](https://www.r-pkg.org/badges/version-last-release/BiCausality)](https://cran.r-project.org/package=BiCausality)\n[![Download](https://cranlogs.r-pkg.org/badges/grand-total/BiCausality)](https://cran.r-project.org/package=BiCausality)\n[![arXiv](https://img.shields.io/badge/stat.ME-arXiv%3A2205.06131-B31B1B.svg)](https://arxiv.org/abs/2205.06131)\n[![](https://img.shields.io/badge/doi-10.1016%2Fj.heliyon.2023.e15947-yellow)](https://doi.org/10.1016/j.heliyon.2023.e15947)\n[![License](https://img.shields.io/badge/License-MIT-orange.svg)](https://spdx.org/licenses/MIT.html)\n\nA framework to infer causality on binary data using techniques in frequent pattern mining and estimation statistics. Given a set of individual vectors S={x} where x(i) is a realization value of binary variable i, the framework infers empirical causal relations of binary variables i,j from S in a form of causal graph G=(V,E) where V is a set of nodes representing binary variables and there is an edge from i to j in E if the variable i causes j. The framework determines dependency among variables as well as analyzing confounding factors before deciding whether i causes j. \n\nNote: The causal relations inferred by this work is not the real causal relations; they are empirical causal relations that needed\nto be validated. Our main goal is to develop an exploratory data analysis tools to pinpoint possible causal relations to support\nresearchers before the validation in the field studies to find real causal relations. \n\nInstallation\n------------\n\nFor the newest version on github, please call the following command in R terminal.\n\n\n``` r\nremotes::install_github(\"DarkEyes/BiCausality\")\n```\nThis requires a user to install the \"remotes\" package before installing BiCausality.\n\n\nExample: Inferred binary causal graph from simulation\n----------------------------------------------------------------------------------\nIn the first step, we generate a simulation dataset as an input.\n``` r\nseedN\u003c-2022\n\nn\u003c-200 # 200 individuals\nd\u003c-10 # 10 variables\nmat\u003c-matrix(nrow=n,ncol=d) # the input of framework\n\n#Simulate binary data from binomial distribution where the probability of value being 1 is 0.5.\nfor(i in seq(n))\n{\n  set.seed(seedN+i)\n  mat[i,] \u003c- rbinom(n=d, size=1, prob=0.5)\n}\n\nmat[,1]\u003c-mat[,2] | mat[,3]  # 1 causes by 2 and 3\nmat[,4] \u003c-mat[,2] | mat[,5] # 4 causses by 2 and 5\nmat[,6] \u003c- mat[,1] | mat[,4] # 6 causes by 1 and 4\n\n```\n\nWe use the following function to infer whether X causes Y.\n```r\n# Run the function\nlibrary(BiCausality)\nresC\u003c-BiCausality::CausalGraphInferMainFunc(mat = mat,CausalThs=0.1, nboot =50, IndpThs=0.05)\n```\nThe result of the adjacency matrix of the directed causal graph is below:\n\n```r\nresC$CausalGRes$Ehat\n     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]\n [1,]    0    0    0    0    0    1    0    0    0     0\n [2,]    1    0    0    1    0    0    0    0    0     0\n [3,]    1    0    0    0    0    0    0    0    0     0\n [4,]    0    0    0    0    0    1    0    0    0     0\n [5,]    0    0    0    1    0    0    0    0    0     0\n [6,]    0    0    0    0    0    0    0    0    0     0\n [7,]    0    0    0    0    0    0    0    0    0     0\n [8,]    0    0    0    0    0    0    0    0    0     0\n [9,]    0    0    0    0    0    0    0    0    0     0\n[10,]    0    0    0    0    0    0    0    0    0     0\n```\nThe value in the element EValHat[i,j] represents that i causes j if the value is not zero. For example, EValHat[2,1] = 1 implies node 2 causes node 1, which is correct since node 1 have nodes 2 and 3 as causal nodes.\n\nThe directed causal graph also can be plot using the code below.\n```r\nlibrary(igraph)\nnet \u003c- graph_from_adjacency_matrix(resC$CausalGRes$Ehat ,weighted = NULL)\nplot(net, edge.arrow.size = 0.3, vertex.size =20 , vertex.color = '#D4C8E9',layout=layout_with_kk)\n```\nThe plot is below.\n\n\u003cimg src=\"https://github.com/DarkEyes/BiCausality/blob/master/man/FIG/causalGraph.png\" width=\"550\"\u003e\n\n\nFor the causal relation of variables 2 and 1, we can use the command below to see further information.\n\n**Note that the odd difference between X and Y denoted oddDiff(X,Y) is define as\n|P (X = 1, Y = 1) P (X = 0, Y = 0) −P (X = 0, Y = 1) P (X = 1, Y = 0)|.  If X is directly proportional to Y, then oddDiff(X,Y) is close to 1. If X is inverse of Y, then oddDiff(X,Y) is close to -1. If X and Y have no association, then oddDiff(X,Y) is close to zero.\n\n```r\nresC$CausalGRes$causalInfo[['2,1']]\n```\nSuppose Y is variable 1 and X is variable 2, the results are below.\n\n```r\n#This value represents the 95th percentile confidence interval of P(Y=1|X=1). \n$CDirConfValInv\n 2.5% 97.5% \n    1     1 \n#This value represents the 95th percentile confidence interval of |P(Y=1|X=1) - P(X=1|Y=1)|.\n$CDirConfInv\n     2.5%     97.5% \n0.3217322 0.4534494 \n\n#This value represents the mean of |P(Y=1|X=1) - P(X=1|Y=1)|.\n$CDirmean\n[1] 0.3787904\n\n#The test that has the null hypothesis that |P(Y=1|X=1) - P(X=1|Y=1)| below\n#or equal the argument of parameter \"CausalThs\" and the alternative hypothesis\n#is that |P(Y=1|X=1) - P(X=1|Y=1)| is greater than \"CausalThs\".\n$testRes2\n\n\tWilcoxon signed rank test with continuity correction\n\ndata:  abs(bCausalDirDist)\nV = 1275, p-value = 3.893e-10\nalternative hypothesis: true location is greater than 0.1\n\n\n#The test that has the null hypothesis that |oddDiff(X,Y)| below \n#or equal the argument of parameter \"IndpThs\" and the alternative hypothesis is\n#that |oddDiff(X,Y)| is greater than \"IndpThs\". \n$testRes1\n\n\tWilcoxon signed rank test with continuity correction\n\ndata:  abs(bSignDist)\nV = 1275, p-value = 3.894e-10\nalternative hypothesis: true location is greater than 0.05\n\n#If the test above rejects the null hypothesis with the significance threshold\n#alpha (default alpha=0.05), then the value \"sign=1\", otherwise, it is zero.\n$sign\n[1] 1\n\n#This value represents the 95th percentile confidence interval of oddDiff(X,Y)\n$SignConfInv\n      2.5%      97.5% \n0.08670325 0.13693900 \n\n#This value represents the mean of oddDiff(X,Y)\n$Signmean\n[1] 0.1082242\n```\n\n\nCitation\n----------------------------------------------------------------------------------\nAmornbunchornvej, Chainarong, Navaporn Surasvadi, Anon Plangprasopchok, and Suttipong Thajchayapong. \"Framework for inferring empirical causal graphs from binary data to support multidimensional poverty analysis.\"  Heliyon 9, no. 5 (2023): e15947.  \u003ca href=https://doi.org/10.1016/j.heliyon.2023.e15947\u003ehttps://doi.org/10.1016/j.heliyon.2023.e15947\u003c/a\u003e   \u003ca href=\"https://arxiv.org/abs/2205.06131\"\u003earXiv\u003c/a\u003e.  \n\nContact\n----------------------------------------------------------------------------------\n- Developer: C. Amornbunchornvej\u003cdiv itemscope itemtype=\"https://schema.org/Person\"\u003e\u003ca itemprop=\"sameAs\" content=\"https://orcid.org/0000-0003-3131-0370\" href=\"https://orcid.org/0000-0003-3131-0370\" target=\"orcid.widget\" rel=\"noopener noreferrer\" style=\"vertical-align:top;\"\u003e\u003cimg src=\"https://orcid.org/sites/default/files/images/orcid_16x16.png\" style=\"width:1em;margin-right:.5em;\" alt=\"ORCID iD icon\"\u003ehttps://orcid.org/0000-0003-3131-0370\u003c/a\u003e\u003c/div\u003e\n- \u003ca href=\"https://www.nectec.or.th\"\u003eStrategic Analytics Networks with Machine Learning and AI (SAI)\u003c/a\u003e, \u003ca href=\"https://www.nectec.or.th/en/\"\u003eNECTEC\u003c/a\u003e, Thailand\n- Homepage: \u003ca href=\"https://sites.google.com/view/amornbunchornvej/home\"\u003eLink\u003c/a\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkeyes%2Fbicausality","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarkeyes%2Fbicausality","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkeyes%2Fbicausality/lists"}