derive_formula {theorytools}R Documentation

Derive Formulae From Augmented DAG

Description

Uses the form attribute of edges in an augmented DAG to construct formulae for the relationship between exposure and outcome.

Usage

derive_formula(x, exposure, outcome, data = NULL, ...)

Arguments

x

An object of class dagitty.

exposure

Atomic character, indicating the exposure node in x.

outcome

Atomic character, indicating the outcome node in x.

data

Optional, a data.frame to be used as environment for the formulae. Default: NULL

...

Additional arguments, passed to adjustmentSets

Details

The form attribute of an augmented DAG of class dagitty should contain information about the functional form for the relationships specified in the DAG. For this function, the form attribute must be an additive function as also accepted by formula. The form attribute may contain a leading intercept and constant slopes, which will be parsed out. If the form attribute does not meet these requirements, the resulting formula may be invalid. For example:

Value

A list of objects with class formula.

See Also

hasArg get_edges adjustmentSets

Examples

x <- dagitty::dagitty('dag {
C
O
X
Y
O <- X [form="I(X^2)"]
C -> X
Y -> O [form="Y*X"]
}')
f1 <- derive_formula(x, outcome = "O", exposure = "X")
f2 <- derive_formula(x, outcome = "O", exposure = "Y")

[Package theorytools version 0.1.2 Index]