audit_formula: Audit the Formula Used for Causal Inference

View source: R/utils.R

audit_formulaR Documentation

Audit the Formula Used for Causal Inference

Description

Audit the formula used for causal inference.

Usage

audit_formula(data, formula, exposure.name, extra.names)

Arguments

data

Dataframe of raw data.

formula

Formula with at least 1 exposure and 1 extra variable.

exposure.name

The name of the exposure variable.

extra.names

Character vector with the names of the extra variable.

Details

The formula and the variables used must be validated to avoid problems. All formula must have at least 1 outcome variable, 1 exposure variable and 1 extra variable. The extra variables can be confounds, instrumental variable, etc. depending on the context.

Value

List with outcome.name, exposure.name and extra.names of variables.

Examples

out <- audit_formula(
 iris, formula = Sepal.Length ~ Species * Sepal.Width,
 exposure.name = "Species", extra.names = "Sepal.Width")
# return a list with all 3 variable names
stopifnot(length(out) == 3)

FrankLef/fciR documentation built on Nov. 12, 2023, 6:09 a.m.