setup_profile: Define a 'treatment_profile' object

View source: R/treatment_profile.R

setup_profileR Documentation

Define a treatment_profile object

Description

For general mediation analysis, we need to provide counterfactuals for both the outcome and mediator components of each sample. That is, we need to understand Y(t, M(t')) where t and t' may not be the same. treatment_profile classes place some more structural requirements on treatment profiles, so that later effect estimation can make simplifying assumptions. This function creates a treatment profile from a collection of possible mediator and outcome treatments.

Usage

setup_profile(x, t_mediator = NULL, t_outcome = NULL)

Arguments

x

An object of class multimedia specifying the complete mediation analysis DAG. The treatment, mediator, and outcome names are necessary to build a profile of counterfactual treatments across each of these variables.

t_mediator

A data.frame whose columns store treatment names and whose values are the treatment assignments to each sample (row). Defaults to NULL, in which case this type of data.frame is constructed from the treatment assignments in the mediation_data's ⁠@treatment⁠ slot. Each column must be either a numeric or factor variable.

t_outcome

A data.frame analogous to t_mediator, but applying to the outcome node.

Value

An object of class treatment_profile giving treatment assignments for both mediation and outcome terms.

See Also

check_profile

Examples

exper <- demo_spline(tau = c(2, 1)) |>
    mediation_data(starts_with("outcome"), "treatment", "mediator")
fit <- multimedia(exper) |>
    estimate(exper)

t1 <- data.frame(treatment = factor(rep(c(0, 1), each = 5)))
profile <- setup_profile(fit, t_mediator = t1, t_outcome = t1)
profile

t2 <- data.frame(treatment = factor(rep(0, 10)))
profile <- setup_profile(fit, t_mediator = t1, t_outcome = t2)
profile

multimedia documentation built on Sept. 30, 2024, 9:28 a.m.