{"id":32209565,"url":"https://github.com/integrated-inferences/causalqueries","last_synced_at":"2026-02-13T16:18:23.078Z","repository":{"id":36966656,"uuid":"186861431","full_name":"integrated-inferences/CausalQueries","owner":"integrated-inferences","description":"Bayesian inference from binary causal models","archived":false,"fork":false,"pushed_at":"2025-09-28T19:31:20.000Z","size":43220,"stargazers_count":30,"open_issues_count":13,"forks_count":10,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-10-09T06:26:30.714Z","etag":null,"topics":["bayes","causal","dags","mixedmethods","stan"],"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/integrated-inferences.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","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":"2019-05-15T16:08:44.000Z","updated_at":"2025-07-23T12:08:53.000Z","dependencies_parsed_at":"2023-08-28T13:44:29.364Z","dependency_job_id":"4fb79ff5-4368-4de8-b8ee-f57f4a288d90","html_url":"https://github.com/integrated-inferences/CausalQueries","commit_stats":null,"previous_names":["macartan/causalqueries"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/integrated-inferences/CausalQueries","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/integrated-inferences%2FCausalQueries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/integrated-inferences%2FCausalQueries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/integrated-inferences%2FCausalQueries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/integrated-inferences%2FCausalQueries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/integrated-inferences","download_url":"https://codeload.github.com/integrated-inferences/CausalQueries/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/integrated-inferences%2FCausalQueries/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280389996,"owners_count":26322648,"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":["bayes","causal","dags","mixedmethods","stan"],"created_at":"2025-10-22T06:10:05.353Z","updated_at":"2025-10-22T06:10:07.096Z","avatar_url":"https://github.com/integrated-inferences.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CausalQueries\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/CausalQueries)](https://CRAN.R-project.org/package=CausalQueries)\n[![CRAN downloads total](https://cranlogs.r-pkg.org/badges/grand-total/CausalQueries)](https://CRAN.R-project.org/package=CausalQueries)\n[![CRAN downloads monthly](https://cranlogs.r-pkg.org/badges/CausalQueries)](https://cran.r-project.org/package=CausalQueries)\n[![DOI](https://zenodo.org/badge/186861431.svg)](https://doi.org/10.5281/zenodo.14191700)\n\u003c!-- badges: end --\u003e\n\n`CausalQueries` is a package that lets you declare binary causal models, update beliefs about causal types given data and calculate arbitrary estimands. Model definition is implemented via a `dagitty` style syntax. Updating is implemented in `stan`. \n\n* See vignettes for a guide to getting started.\n\n* See [here](https://macartan.github.io/assets/pdf/papers/2024_CausalQueries.pdf) for a guide to using `CausalQueries` along with many examples of causal models  \n\n* See [website](https://integrated-inferences.github.io/CausalQueries/) for a comprehensive overview of `CausalQueries`\n\n \n\n## Installation\n\nTo install the latest stable release of `CausalQueries`:\n\n```\ninstall.packages(\"CausalQueries\")\n```\n\nTo install the latest development release :\n\n```\ninstall.packages(\"devtools\")\ndevtools::install_github(\"integrated-inferences/CausalQueries\")\n```\n\n## Helping Out \\\u0026 Contributing\n\n`CausalQueries` is an open and active developer community. We welcome contributions and are excited you are keen to get involved.\nPlease refer to `CONTRIBUTING.md` to get started. \n\n## Causal Models\n\nCausal models are defined by:\n\n* A **directed acyclic graph** (DAG), which provides the set of variables, a causal ordering between them, and a set of assumptions regarding conditional independence. If there is no arrow from `A` to `B` then a change in `A` never induces a change in `B`. \n* **Functional forms**. Functional forms describe the causal relationships between nodes. You often have to make strong assumptions when you specify a functional form; fortunately however if variables are categorical  we do not need functional forms in the usual sense. The DAG implies a set of \"causal types.\" Units can be classed together as of the same causal type if they respond to the same way to other variables.  For instance, a type might be the set of units for which `X=1` and for which `Y=1` if and only if `X=1`. The set of causal types grows rapidly with the number of nodes and the number of nodes pointing into any given node. In this setting imposing functional forms is the same as placing *restrictions on causal types*: such restrictions reduce  complexity but require substantive assumptions. An example of a restriction might be \"`Y` is monotonic in `X`.\"\n* **Priors.** In the standard case, the DAG plus any restrictions imply a set of parameters that combine to form causal types. These are the  parameters we want to learn about. To learn about them we first provide priors over the parameters. With priors specified the causal model is complete (it is a \"probabilistic causal model\") and we are ready for inference.  Setting priors is done using the `set_priors` function and many examples can be seen by typing `? set_priors.R`.\n\n\nA wrinkle:\n\n* It is possible that nodes are related in ways not captured by the DAG. In such cases dotted curves are sometimes placed between nodes on a graph. It is possible to specify such possible **unobservable confounding** in the causal model. This has implications for the parameter space.\n\n## Inference\n\nOur goal is to form beliefs over parameters but also over more substantive estimands:\n\n* With a causal model in hand and data available about some or all of the nodes, it is possible to make use of a generic `stan` model that generates posteriors over the parameter vector. \n\n*  Given updated (or prior) beliefs about parameters it is possible to calculate causal estimands of inference from a causal model. For example \"What is the probability that `X` was the cause of `Y` given `X=1`, `Y=1` and `Z=1`.\"\n\n\n## Credits etc\n\nThe approach used in `CausalQueries` is developed in [Humphreys and Jacobs 2023](https://macartan.github.io/integrated_inferences/) drawing on  work on probabilistic causal models described in Pearl's [*Causality*](https://www.cambridge.org/core/books/causality/B0046844FAE10CBF274D4ACBDAEB5F5B) (Pearl, 2009). We thank Ben Goodrich who provided generous insights on using `stan` for this project. We thank Alan M Jacobs for key work developing the framework underlying the package. Our thanks to Jasper Cooper for contributions generating a generic function to create Stan code, to [Clara Bicalho](https://clarabicalho.github.io/) who helped figure out the syntax for causal statements, to [Julio S. Solís Arce](https://www.gov.harvard.edu/directory/julio-s-solis-arce/) who made many key contributions figuring out how to simplify the specification of priors, and to [Merlin Heidemanns](https://merlinheidemanns.github.io/website/) who figured out the `rstantools` integration and made myriad code improvements. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegrated-inferences%2Fcausalqueries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintegrated-inferences%2Fcausalqueries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegrated-inferences%2Fcausalqueries/lists"}