Skip to contents

This class ensures appropriate structure of the treatment assignments for mediator and outcome variables. It enforces certain structural requirements (e.g., that the number of samples is the same under the mediator and outcome counterfactuals) using the check_profile function.

See also

setup_profile check_profile

Examples

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

# helpers for defining treatment profiles
t1 <- data.frame(treatment = factor(rep(c(0, 1), each = 5)))
profile <- setup_profile(fit, t_mediator = t1, t_outcome = t1)
profile
#> An object of class "treatment_profile"
#> Slot "t_mediator":
#> $mediator
#>    treatment
#> 1          0
#> 2          0
#> 3          0
#> 4          0
#> 5          0
#> 6          1
#> 7          1
#> 8          1
#> 9          1
#> 10         1
#> 
#> 
#> Slot "t_outcome":
#> $outcome_1
#>    treatment
#> 1          0
#> 2          0
#> 3          0
#> 4          0
#> 5          0
#> 6          1
#> 7          1
#> 8          1
#> 9          1
#> 10         1
#> 
#> $outcome_2
#>    treatment
#> 1          0
#> 2          0
#> 3          0
#> 4          0
#> 5          0
#> 6          1
#> 7          1
#> 8          1
#> 9          1
#> 10         1
#> 
#> 

t2 <- data.frame(treatment = factor(rep(0, 10)))
profile <- setup_profile(fit, t_mediator = t1, t_outcome = t2)
profile
#> An object of class "treatment_profile"
#> Slot "t_mediator":
#> $mediator
#>    treatment
#> 1          0
#> 2          0
#> 3          0
#> 4          0
#> 5          0
#> 6          1
#> 7          1
#> 8          1
#> 9          1
#> 10         1
#> 
#> 
#> Slot "t_outcome":
#> $outcome_1
#>    treatment
#> 1          0
#> 2          0
#> 3          0
#> 4          0
#> 5          0
#> 6          0
#> 7          0
#> 8          0
#> 9          0
#> 10         0
#> 
#> $outcome_2
#>    treatment
#> 1          0
#> 2          0
#> 3          0
#> 4          0
#> 5          0
#> 6          0
#> 7          0
#> 8          0
#> 9          0
#> 10         0
#> 
#>