sensitivity | R Documentation |
For causal identification, mediation analysis relies on several untestable assumptions. One important one is that there is no confounding between the counterfactual mediator and outcome variables. Even though we can never know whether this exists, we can measure the sensitivity of our conclusions to the existence/strength of such a confounder. In this function, we approach this by inducing (unallowable) correlation between the mediator and outcome model residuals, simulate forward, and see how the estimated overall indirect effect changes.
sensitivity(
model,
exper,
confound_ix = NULL,
rho_seq = NULL,
n_bootstrap = 100,
progress = TRUE,
...
)
model |
A |
exper |
The original |
confound_ix |
A data.frame specifying which mediator/outcome should be allowed to be correlated. Should have two columns: 'mediator' and 'outcome' specifying which pairs of mediators and outcomes should be correlated. Defaults to NULL, which creates a data.frame with no rows (and so enforcing independence between mediators and outcomes) |
rho_seq |
We will evaluate correlations Cor(e', e) between mediation and outcome model errors ranging along this grid. Defaults to NULL, which internally sets the sequence to rho = (-0.9, -0.7 ..., 0.7, 0.9). |
n_bootstrap |
The number of bootstrap resamples used to build confidence bands around the sensitivity curves. Defaults to 100. |
progress |
A logical indicating whether to show a progress bar. |
... |
Additional keyword arguments passed to |
A data.frame
giving the outputs of indirect_overall
across many
values of the correlation rho.
xy_data <- demo_spline()
exper <- mediation_data(
xy_data, starts_with("outcome"), "treatment", "mediator"
)
model <- multimedia(
exper,
outcome_estimator = glmnet_model(lambda = 1e-2)
) |>
estimate(exper)
rho_seq <- c(-0.2, 0, 0.2)
confound_ix <- expand.grid(mediator = 1, outcome = 1:2)
sensitivity(model, exper, confound_ix, rho_seq, n_bootstrap = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.