Estimate direct effects associated with a multimedia model. These estimates
are formed using Equation (10) of our paper. Rather than providing this
average, this function returns the estimated difference for each $j$. To
average across all j, this result can be passed to the ' effect_summary
function.
Arguments
- model
An object of class multimedia containing the estimated mediation and outcome models whose mediation and outcome predictions we want to compare.
- exper
An object of class multimedia_data containing the mediation and outcome data from which the direct effects are to be estimated.
- t1
The reference level of the treatment to be used when computing the direct effect.
- t2
The alternative level of the treatment to be used when computing the direct effect.
Value
A data.frame summarizing the direct effects associated with different settings of j in the equation above.
Examples
# example with null data
exper <- demo_joy() |>
mediation_data("PHQ", "treatment", starts_with("ASV"))
fit <- multimedia(exper) |>
estimate(exper)
direct_effect(fit)
#> outcome indirect_setting contrast direct_effect
#> 1 PHQ Control Control - Treatment -0.1033701
#> 2 PHQ Treatment Control - Treatment -0.1033701
direct_effect(fit, t1 = 2, t2 = 1)
#> outcome indirect_setting contrast direct_effect
#> 1 PHQ Control Treatment - Control 0.1033701
#> 2 PHQ Treatment Treatment - Control 0.1033701
direct_effect(fit, t1 = 2, t2 = 2)
#> outcome indirect_setting contrast direct_effect
#> 1 PHQ Control Treatment - Treatment 0
#> 2 PHQ Treatment Treatment - Treatment 0
# example with another dataset
exper <- demo_spline(tau = c(2, 1)) |>
mediation_data(starts_with("outcome"), "treatment", "mediator")
fit <- multimedia(exper) |>
estimate(exper)
direct_effect(fit)
#> outcome indirect_setting contrast direct_effect
#> 1 outcome_1 0 0 - 1 -1.885532
#> 2 outcome_2 0 0 - 1 -1.054736
#> 3 outcome_1 1 0 - 1 -1.885532
#> 4 outcome_2 1 0 - 1 -1.054736