Index | Topics |
causal inference {bnlearn} | R Documentation |
Perform causal inference
Description
Perform interventions and counterfactuals, using Bayesian networks as causal models.
Usage
# network transformations used in causal inference.
mutilated(x, evidence)
twin(x)
# causal inference types.
intervention(x, evidence)
counterfactual(x, evidence, merging = TRUE)
Arguments
x |
an object of class |
evidence |
a list, in the same format as the evidence for likelihood weighting (see |
merging |
a boolean value. If |
Details
mutilated()
constructs the mutilated network arising from an ideal intervention setting the
nodes involved to the values specified by evidence
.
twin()
constructs the twin network required to compute counterfactuals, separating noise
(exogenous) from functional (factual) nodes and adding counterfactual nodes.
intervention()
is an alias of mutilated()
.
counterfactual()
constructs the twin network and introduces a counterfactual (that is, an
intervention on the counterfactual nodes) before applying node merging (optional). The intervention in
evidence
is specified using the labels of the nodes in x
, and is then applied to
the corresponding counterfactual nodes.
Both twin()
and counterfactual()
label nodes as follows:
-
a counterfactual node has the label of the correspoding factual node with a period appended (as in
paste0(label, ".")
). -
a noise node has the label of the corresponding factual node with a
"u"
prepended (as inpaste0("u", label)
).
Value
A bn
or bn.fit
object, depending on the class of x
.
Author(s)
Marco Scutari
References
Balke A, Pearl J (2022). "Probabilistic Evaluation of Counterfactual Queries." Probabilistic and Causal Inference: The Works of Judea Pearl, 237–254. The original is in the Proceddings of AAAI, 1994.
Graham D, Lee CM, Perov Y (2019). "Copy, Paste, Infer: A Robust Analysis of Twin Networks for Counterfactual Inference." NeurIPS19 CausalML workshop.
Koller D, Friedman N (2009). Probabilistic Graphical Models: Principles and Techniques. MIT Press.
Shpitser I, PearlJ (2007). "What counterfactuals can be tested." Proceedings of the 23rd Conference on Uncertainty in Artificial Intelligence (UAI), 352–359.
Examples
# example from Graham, Lee and Perov.
dag = model2network("[C][A|C][B|C][D|A:B]")
intervention(dag, evidence = list(A = 0))
twin(dag)
counterfactual(dag, evidence = list(A = 0), merging = FALSE)
counterfactual(dag, evidence = list(A = 0), merging = TRUE)
Index | Topics |