
Estimate a causal effect using DAG-guided backdoor adjustment
Source:R/causal_dag.R
causal_estimate_effect.RdIdentifies a valid backdoor-adjustment set from the supplied DAG (unless one is provided manually) and then fits an adjusted outcome model conditional on that set. Two estimators are available:
Arguments
- data
Data frame with columns covering at least
exposure,outcome, and the chosen adjustment set.- dag
A
dagittyDAG.- exposure, outcome
Character column names.
- adjustment
Optional character vector overriding the automatic adjustment set.
- effect, type
Forwarded to
causal_adjustment_set().- estimator
One of
"lm"(default) or"bart"(requiresdbarts).- delta
Numeric finite-difference step used by the BART estimator. Defaults to the interquartile range of
exposuredivided by two.- bart_kwargs
Optional named list of extra arguments forwarded to
dbarts::bart()(e.g.ndpost,nskip,seed).
Value
A edaphos_causal_effect object with:
- model
The fitted estimator (either an
lmor adbarts::bartobject).- estimator
Character;
"lm"or"bart".- adjustment
The adjustment set used.
- effect
Numeric direct effect.
- effect_ci
95 % CI (asymptotic for
"lm", posterior quantile for"bart").- effect_naive
Coefficient from the unadjusted
lm(outcome ~ exposure)for contrast.
Details
estimator = "lm"— closed-form linear regression \(Y = \beta_0 + \beta_{\text{exposure}}\,X + \sum_{z\in Z}\gamma_z z + \varepsilon\). The regression coefficient onexposureis the direct causal effect. Confidence intervals follow from OLS asymptotics.estimator = "bart"— non-linear Bayesian Additive Regression Trees (Chipman, George & McCulloch 2010), via thedbartsSuggests dependency. The effect ofexposureis computed as the average partial derivative \(\bar{\partial} = \frac{1}{n}\sum_i \bigl[\widehat{E}[Y\mid X=x_i+\delta, Z=z_i] - \widehat{E}[Y\mid X=x_i, Z=z_i]\bigr] / \delta\) averaged over the training data. A 95 % credible interval is recovered from the BART posterior draws.