| estADMG | R Documentation |
The main user-facing function of the package. Given a causal graph specified as an acyclic directed mixed graph (ADMG), this function automatically determines the identifiability status of the treatment effect and dispatches to the appropriate estimator:
If the treatment is fixable (i.e., backdoor-adjustable),
estimation proceeds via .call_backdoor, returning G-computation,
IPW, one-step (AIPW), and TMLE estimators.
If the treatment is primal fixable (extended front-door
functional), estimation proceeds via .call_nps, returning
one-step and TMLE estimators.
If the treatment is neither fixable nor primal fixable, the function stops with an error.
A message is also printed indicating whether the graph is nonparametrically saturated, in which case the returned estimators are semiparametrically efficient.
estADMG(
a = NULL,
data = NULL,
vertices = NULL,
di_edges = NULL,
bi_edges = NULL,
treatment = NULL,
outcome = NULL,
multivariate.variables = NULL,
graph = NULL,
superlearner.seq = FALSE,
superlearner.Y = FALSE,
superlearner.A = FALSE,
superlearner.M = FALSE,
superlearner.L = FALSE,
crossfit = FALSE,
K = 5,
ratio.method.L = "bayes",
ratio.method.M = "bayes",
dnorm.formula.L = NULL,
dnorm.formula.M = NULL,
lib.seq = c("SL.glm", "SL.earth", "SL.ranger", "SL.mean"),
lib.L = c("SL.glm", "SL.earth", "SL.ranger", "SL.mean"),
lib.M = c("SL.glm", "SL.earth", "SL.ranger", "SL.mean"),
lib.Y = c("SL.glm", "SL.earth", "SL.ranger", "SL.mean"),
lib.A = c("SL.glm", "SL.earth", "SL.ranger", "SL.mean"),
formulaY = "Y ~ .",
formulaA = "A ~ .",
linkY_binary = "logit",
linkA = "logit",
n.iter = 500,
cvg.criteria = 0.01,
truncate_lower = 0,
truncate_upper = 1,
zerodiv.avoid = 0
)
a |
Numeric scalar or length-two numeric vector specifying the treatment
level(s) of interest. The treatment must be coded as 0/1. If a scalar,
the function returns |
data |
A data frame containing all variables listed in |
vertices |
A character vector of variable names in the causal graph.
Ignored if |
di_edges |
A list of length-two character vectors specifying directed
edges. For example, |
bi_edges |
A list of length-two character vectors specifying bidirected
edges. For example, |
treatment |
A character string naming the binary (0/1) treatment
variable in |
outcome |
A character string naming the outcome variable in |
multivariate.variables |
A named list mapping compound vertex names to
their column names in |
graph |
A graph object created by |
superlearner.seq |
Logical. If |
superlearner.Y |
Logical. If |
superlearner.A |
Logical. If |
superlearner.M |
Logical. If |
superlearner.L |
Logical. If |
crossfit |
Logical. If |
K |
A positive integer specifying the number of cross-fitting folds.
Used only when |
ratio.method.L |
A character string specifying the method for estimating density ratios for variables in L (primal fixable case only). Options are:
|
ratio.method.M |
A character string specifying the method for
estimating density ratios for variables in M (primal fixable case only).
Same options as |
dnorm.formula.L |
An optional named list of regression formulas for
variables in L, used when |
dnorm.formula.M |
An optional named list of regression formulas for
variables in M, used when |
lib.seq |
SuperLearner library for sequential regression.
Default is |
lib.L |
SuperLearner library for density ratio estimation for L.
Default is |
lib.M |
SuperLearner library for density ratio estimation for M.
Default is |
lib.Y |
SuperLearner library for outcome regression.
Default is |
lib.A |
SuperLearner library for propensity score estimation.
Default is |
formulaY |
A formula or character string for outcome regression of Y on
its Markov pillow. Used only when |
formulaA |
A formula or character string for propensity score regression
of A on its Markov pillow. Used only when |
linkY_binary |
A character string specifying the link function for
outcome regression when Y is binary and |
linkA |
A character string specifying the link function for propensity
score regression when |
n.iter |
Maximum number of TMLE iterations. Default is 500. |
cvg.criteria |
Numeric. TMLE convergence threshold. The iterative
update stops when |
truncate_lower |
Numeric. Propensity score values below this threshold
are clipped. Default is |
truncate_upper |
Numeric. Propensity score values above this threshold
are clipped. Default is |
zerodiv.avoid |
Numeric. Density ratio or propensity score values below
this threshold are clipped to prevent division by zero.
Default is |
The return structure depends on the identifiability path:
A named list with components TMLE,
Onestep, IPW, and Gcomp, plus per-treatment-level
sub-lists.
A named list with components
TMLE and Onestep.
# Fixable graph: simple backdoor adjustment
test <- estADMG(
a = 1,
data = data_backdoor,
vertices = c('A', 'Y', 'X'),
di_edges = list(c('X', 'A'), c('X', 'Y'), c('A', 'Y')),
treatment = 'A',
outcome = 'Y'
)
# Primal fixable graph: extended front-door functional
test <- estADMG(
a = 1,
data = data_example_a,
vertices = c('A', 'M', 'L', 'Y', 'X'),
bi_edges = list(c('A', 'Y')),
di_edges = list(c('X', 'A'), c('X', 'M'), c('X', 'L'),
c('X', 'Y'), c('M', 'Y'), c('A', 'M'),
c('A', 'L'), c('M', 'L'), c('L', 'Y')),
treatment = 'A',
outcome = 'Y',
multivariate.variables = list(M = c('M.1', 'M.2'))
)
# ACE estimation E(Y(1)) - E(Y(0))
test <- estADMG(
a = c(1, 0),
data = data_example_a,
vertices = c('A', 'M', 'L', 'Y', 'X'),
bi_edges = list(c('A', 'Y')),
di_edges = list(c('X', 'A'), c('X', 'M'), c('X', 'L'),
c('X', 'Y'), c('M', 'Y'), c('A', 'M'),
c('A', 'L'), c('M', 'L'), c('L', 'Y')),
treatment = 'A',
outcome = 'Y',
multivariate.variables = list(M = c('M.1', 'M.2'))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.