For inference, we often want to work with synthetic negative controls. One way to define them is to specify submodels of the full mediation analysis model. This function defines submodels by removing estimated edges according to a prespecified vector of IDs. For example, setting nulls = "T -> Y" will remove any direct effect when sampling or obtaining predictions for the full mediation analysis model \(hat{Y}\).
Arguments
- multimedia
A fitted object of class multimedia with estimates along all paths in the mediation analysis DAG.
- nulls
A string specifying the indices of edges to ignore. "T->Y", "T->M", and "M->Y" will match all edges between treatment to outcome, treatment to mediator, etc. Otherwise, the vector of indices specifying which edges to ignore.
Value
multimedia A version of the input multimedia model with all edges
matching nulls
removed. Enables sampling of synthetic null controls.
Examples
# example with null data
exper <- demo_joy() |>
mediation_data("PHQ", "treatment", starts_with("ASV"))
fit <- multimedia(exper) |>
estimate(exper)
nullify(fit, "T->M") |>
estimate(exper) |>
indirect_overall()
#> outcome direct_setting contrast indirect_effect
#> 1 PHQ Control Control - Treatment 0
#> 2 PHQ Treatment Control - Treatment 0
nullify(fit, "T->Y") |>
estimate(exper) |>
direct_effect()
#> outcome indirect_setting contrast direct_effect
#> 1 PHQ Control Control - Treatment 0
#> 2 PHQ Treatment Control - 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)
nullify(fit, "T->M") |>
estimate(exper) |>
indirect_overall()
#> outcome direct_setting contrast indirect_effect
#> 1 outcome_1 0 0 - 1 0
#> 2 outcome_2 0 0 - 1 0
#> 3 outcome_1 1 0 - 1 0
#> 4 outcome_2 1 0 - 1 0
nullify(fit, "T->Y") |>
estimate(exper) |>
direct_effect()
#> outcome indirect_setting contrast direct_effect
#> 1 outcome_1 0 0 - 1 0
#> 2 outcome_2 0 0 - 1 0
#> 3 outcome_1 1 0 - 1 0
#> 4 outcome_2 1 0 - 1 0