null_contrast: Compare Effects from Experimental vs. Null Mediation Data

View source: R/inference.R

null_contrastR Documentation

Compare Effects from Experimental vs. Null Mediation Data

Description

One way to calibrate our conclusions from complex workflows is to see how they would look on data where we know that there is no effect. This function compares estimators f between real and synthetic null data, where the null removes a set of edges according to the nullfication argument.

Usage

null_contrast(model, exper, nullification = "T->Y", f = direct_effect)

Arguments

model

An object of class multimedia with specified mediation and outcome models that we want to re-estimate across B bootstrap samples.

exper

An object of class multimedia_data containing the mediation and outcome data from which the direct effects are to be estimated.

nullification

A string specifying the types of edges whose effects we want to remove in the null samples. Valid options are "T->Y" (the default), "T->M", "M->Y", which remove direct effects, treatment to mediator effects, and mediator to treatment effects, respectively.

f

The estimator that we want to compare between real and null data. This is assumed to be a function taking counterfactual samples, for example direct_effects or indirect_effects.

Value

A data.frame containing estimates on the real and synthetic data for every coordinate in the estimator f. The column source specifies whether the estimate was calculated using real or synthetic null data.

See Also

null_contrast fdr_summary

Examples

# example with null data - notice synthetic data has larger effect.
exper <- demo_joy() |>
    mediation_data("PHQ", "treatment", starts_with("ASV"))
multimedia(exper) |>
    estimate(exper) |>
    null_contrast(exper)

# example with another dataset - synthetic effect is smaller.
exper <- demo_spline(tau = c(2, 1)) |>
    mediation_data(starts_with("outcome"), "treatment", "mediator")
multimedia(exper) |>
    estimate(exper) |>
    null_contrast(exper)

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