View source: R/robustmediate.R
| robustmediate | R Documentation |
Fits treatment, mediator, and outcome models for causal mediation analysis
with continuous treatments using inverse probability weighting (IPW), and
returns a precomputed robmedfit object for plotting and diagnostics.
robustmediate(
treatment_formula,
mediator_formula,
outcome_formula,
data,
ref_dose = NULL,
dose_grid = NULL,
R = 500,
alpha = 0.05,
covariates = NULL,
cluster_var = NULL,
family_treatment = stats::gaussian(),
family_mediator = stats::gaussian(),
family_outcome = stats::gaussian(),
spline_df = 4,
evalue_seq = seq(1, 10, by = 0.25),
rho_seq = seq(-1, 1, by = 0.05),
verbose = TRUE
)
treatment_formula |
Formula for the treatment model
(for example, |
mediator_formula |
Formula for the mediator model
(for example, |
outcome_formula |
Formula for the outcome model
(for example, |
data |
A data frame containing all analysis variables. |
ref_dose |
Reference dose value. Defaults to the sample mean of the treatment variable. |
dose_grid |
Numeric vector of dose values over which NDE, NIE, and TE are evaluated. Defaults to 100 evenly spaced points across the observed treatment range. |
R |
Number of bootstrap replicates. Default is |
alpha |
Significance level. Default is |
covariates |
Covariate names for balance diagnostics. If |
cluster_var |
Optional clustering variable name. |
family_treatment |
GLM family for the treatment model.
Default is |
family_mediator |
GLM family for the mediator model.
Default is |
family_outcome |
GLM family for the outcome model.
Default is |
spline_df |
Degrees of freedom for spline-based effect summaries.
Default is |
evalue_seq |
Sequence of E-values used to build the sensitivity surface.
Default is |
rho_seq |
Sequence of |
verbose |
Logical; if |
An object of class "robmedfit" containing:
modelsFitted treatment, mediator, and outcome models.
balanceBalance statistics before and after weighting.
effectsDose-response summaries for NDE, NIE, and TE, including bootstrap intervals.
sensitivityBivariate E-value and rho sensitivity surface.
meditcvPathway-specific medITCV object from
sensitivity_meditcv().
meditcv_profilemedITCV robustness profile from
sensitivity_meditcv_profile().
clusterCluster information, or NULL if clustering was not
used.
metaCall, variable names, dose settings, bootstrap settings, and sample information.
n <- 400
Z1 <- rnorm(n)
Z2 <- rbinom(n, 1, 0.5)
X <- 0.5 * Z1 + 0.3 * Z2 + rnorm(n)
M <- 0.4 * X + 0.2 * Z1 + rnorm(n)
Y <- 0.3 * X + 0.5 * M + 0.1 * Z1 + rnorm(n)
dat <- data.frame(Y, X, M, Z1, Z2)
fit <- robustmediate(
treatment_formula = X ~ Z1 + Z2,
mediator_formula = M ~ X + Z1 + Z2,
outcome_formula = Y ~ X + M + Z1 + Z2,
data = dat,
R = 100
)
print(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.