select_controls {theorytools} | R Documentation |
Select Covariate Adjustment Sets from Data
Description
Wraps adjustmentSets to construct a dataset with covariates that (asymptotically) allow unbiased estimation of causal effects from observational data.
Usage
select_controls(
x,
data,
exposure = NULL,
outcome = NULL,
which_set = c("first", "sample", "all"),
...
)
Arguments
x |
An input graph of class |
data |
A |
exposure |
Atomic character, name of the exposure variable. |
outcome |
Atomic character, name of the outcome variable. |
which_set |
Atomic character, indicating which set of covariates to
select in case there are multiple. Valid choices are in
|
... |
Other arguments passed to adjustmentSets |
Value
If which_set = "all"
, returns a list of data.frames
to allow for
sensitivity analyses. Otherwise, returns a data.frame
.
See Also
Examples
dag <- dagitty::dagitty('dag {x -> y}')
df <- data.frame(x = rnorm(10), y = rnorm(10))
df1 <- select_controls(dag, df, exposure = "x", outcome = "y")
class(df1) == "data.frame"
df2 <- select_controls(dag, df, exposure = "x", outcome = "y", which_set = "sample")
class(df2) == "data.frame"
lst1 <- select_controls(dag, df, exposure = "x", outcome = "y", which_set = "all")
class(lst1) == "list"
[Package theorytools version 0.1.2 Index]