Kagu
Bayesian graphical causal models in R. Specify a causal DAG, fit each node with a Gaussian process, and estimate interventional effects with full posterior uncertainty.
remotes::install_github(“causalabs/kagu-r”)
Overview
Kagu fits Bayesian graphical causal models (GCMs). You describe a system as a directed acyclic graph (DAG) of which variables cause which, and Kagu fits each node as an independent Gaussian process of its parents. Causal questions (total effects, conditional effects, dose-response curves) are answered by propagating interventions through that fitted graph, so different questions are queries against the same fitted model.
How it works
The system is represented as structural equations X_i = f_i(Pa(X_i), ε_i). Each f_i is a mechanism fitted as an independent Bayesian model, so the joint distribution factorises over nodes: P(X_1, …, X_n) = ∏ P(X_i | Pa(X_i)).
Effects are computed via the do-operator: fix the treatment node at x (severing its incoming edges), propagate forward through the DAG in topological order, and compare E[Y | do(X = x)] against E[Y | do(X = x')]. Because each node’s mechanism is a Gaussian process, non-linearities and interactions between parents are picked up automatically, without being specified in the model formula.
Learn more
- Quickstart: a first model, fit and queried in a few lines.
- Confounder, mediator, collider, M-bias: four classic DAG patterns compared against OLS.
- Case study: sociality and fitness in ecology: the full version of the example above, including causal discovery and the Table II fallacy.
- Modelling interactions: how the Gaussian process mechanism recovers interactions automatically.
- Causal structure discovery: treating the DAG itself as uncertain and estimating a posterior over structures.