View source: R/10_mediation_inference.R
| mediation_inference | R Documentation |
Step 2 of the TransHDM pipeline: de-biased lasso estimation
following screening (SIS, Step 1). It consists of two
sub-steps:
Step 2.1 — Outcome model (beta): estimates mediator-outcome
effects by regressing the outcome Y on all retained mediators,
the exposure D, and covariates X.
Step 2.2 — Mediator models (alpha): estimates
exposure-mediator effects by regressing each mediator on D
and X.
Both steps support transfer learning. A list of source datasets is row-bound
into one source before estimation. Results are passed to
joint_test (Step 3) for multiple testing.
mediation_inference(
screen_result = NULL,
target_data = NULL,
source_data = NULL,
Y = NULL,
D = NULL,
M = NULL,
X = NULL,
transfer = FALSE,
verbose = TRUE,
ncore = 1
)
screen_result |
An object of class |
target_data |
A data frame containing the target dataset. Required
when |
source_data |
A data frame, or a list of data frames, containing source
datasets (optional, default: |
Y |
Character string specifying the outcome variable name. Required
only when |
D |
Character string specifying the exposure variable name.
Required only when |
M |
Character vector specifying the full set of mediator variable
names (before screening). Required only when |
X |
Character vector specifying covariate variable names.
Required only when |
transfer |
A logical value (default: |
verbose |
A logical value (default: |
ncore |
An integer (default: 1) specifying the number of CPU cores for parallel computation of mediator models. |
The variance estimator follows Algorithm 3 of Tian and Feng (2023). For Gaussian linear models, it assumes unit error variance. Under the required source-target heterogeneity conditions, pooled source and target design information is used to estimate the correlation structure, while the debiasing correction is based on target-domain data. This assumption is not automatically verified by the function.
An object of class "mediation_inference" — a list with:
DE_est: Estimated direct effect of D on Y.
alpha_SIS_est: Named numeric vector of alpha estimates
(exposure-mediator effects) for all mediators in M.
Non-selected mediators are set to zero.
P_alpha_SIS: Named numeric vector of p-values for alpha.
beta_SIS_est: Named numeric vector of beta estimates
(mediator-outcome effects) for all mediators in M.
Non-selected mediators are set to zero.
P_beta_SIS: Named numeric vector of p-values for beta.
M: The full mediator name vector.
M_SIS: Mediators retained after screening.
D: The exposure variable name.
TransHDM, joint_test, SIS
set.seed(123)
target_data <- gen_simData_homo(n = 50, p_x = 3, p_m = 20, rho = 0.1)$data
source_data <- gen_simData_homo(n = 100, p_x = 3, p_m = 20, rho = 0.1,
source = TRUE, transferable = TRUE)$data
M_vars <- paste0("M", 1:20)
X_vars <- paste0("X", 1:3)
# With screening (SIS)
sis <- SIS(target_data, source_data, Y = "Y", D = "D", M = M_vars,
X = X_vars, transfer = TRUE, topN = 10)
infer <- mediation_inference(sis, transfer = TRUE)
# Without screening (use all mediators directly)
infer_ns <- mediation_inference(
target_data = target_data, source_data = source_data,
Y = "Y", D = "D", M = M_vars, X = X_vars,
transfer = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.