sensitivity_perturb | R Documentation |
The more standard sensitivity and sensitivity_pathwise functions support sensitivity analysis to violations in assumptions restricted to specific mediator-outcome pairs. For more general violations, this function allows arbitrary modification of the default, diagonal covariance matrix structure across both mediators and outcomes. This makes it possible to ask what happens when mediators are correlated with one another or when more some pairs of mediator-outcome pairs have much stronger correlation than others.
sensitivity_perturb(
model,
exper,
perturb,
nu_seq = NULL,
n_bootstrap = 100,
progress = TRUE
)
model |
A |
exper |
The original |
perturb |
A matrix towards which the original mediator-outcome covariance should be perturbed. Must have dimension (n_mediators + n_outcomes) x (n_mediators + n_outcomes). |
nu_seq |
The strength of the perturbation towards the matrix perturb. |
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. |
Specifically, it defines a new covariance matrix across mediators and outcomes according to diag(sigma^2_mediator, sigma^2_outcome) + nu * perturb. The estimates sigma^2 are taken from the residuals in the original mediation and outcome models, and perturb and nu are provided by the user.
A date.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)
nu_seq <- c(-0.2, 0.2)
perturb <- matrix(
c(
0, 3, 0,
3, 0, 0,
0, 0, 0
),
nrow = 3, byrow = TRUE
)
sensitivity_perturb(model, exper, perturb, nu_seq, n_bootstrap = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.