Title: | Adaptive Bootstrap Inference for Mediation Analysis with Enhanced Statistical Power |
Version: | 1.1 |
Description: | Assess whether and how a specific continuous or categorical exposure affects the outcome of interest through one- or multi-dimensional mediators using an adaptive bootstrap (AB) approach. The AB method allows to make inference for composite null hypotheses of no mediation effect, providing valid type I error control and thus optimizes statistical power. For more technical details, refer to He, Song and Xu (2024) <doi:10.1093/jrsssb/qkad129>. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
Imports: | boot, stats |
URL: | https://websites.umich.edu/~songlab/software.html#ABIMA, https://github.com/canyi-chen/abima |
BugReports: | https://github.com/canyi-chen/abima/issues |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2024-10-25 16:44:00 UTC; chencanyi |
Author: | Canyi Chen |
Maintainer: | Canyi Chen <cychen.stats@outlook.com> |
Repository: | CRAN |
Date/Publication: | 2024-10-25 23:30:10 UTC |
Adaptive Bootstrap Test in Mediation Analysis with Linear Models or Generalized Linear Models
Description
abYlm.Mglm
conducts an adaptive bootstrap test in a mediation analysis in which mediator M is modeled by a generalized linear model (GLM) and outcome Y is modeled by a linear model (LM). The family of the generalized linear model is specified according to M.family
.
Usage
abYlm.Mglm(
S,
M,
Y,
X = NULL,
covariates_cfder = NULL,
M.family = stats::gaussian(),
s = 1,
s_star = 0,
B = 199,
lambda = 2
)
Arguments
S |
an n-by-1 vector for exposure. |
M |
an n-by-1 vector for mediator. |
Y |
an n-by-1 vector for outcome. |
X |
an n-by-p matrix for p confounders. Do not include intercept in matrix X. In the absence of confounders, matrix is not required to be specified. |
covariates_cfder |
a vector of p confounders to adjust mediation effects, and default is zero (or void). The length of this vector is p, the same as the column dimension of X. |
M.family |
the error distribution and link function for the mediator model. The default family is |
s |
exposure level with default set at 1. |
s_star |
baseline exposure level with default set at 0. |
B |
the number of bootstrap samples with default set at 199. |
lambda |
the tuning parameter used in the adaptive bootstrap procedure with default set at 2. |
Value
NIE refers to natural indirect effect, which is the estimated when a change of exposure S occurs from s_star to s.
p_value_NIE refers to the AB p value for NIE.
NDE refers to natural direct effect, which is estimated when exposure S changes from s_star to s.
p_value_NDE is the p value for NDE.
NTE is the estimated natural total effect when exposure S changes from s_star to s.
p_value_NTE is the p value for NTE.
References
He, Y., Song, P. X. K., and Xu, G. (2023), “Adaptive bootstrap tests for composite null hypotheses in the mediation pathway analysis,” Journal of the Royal Statistical Society Series B: Statistical Methodology, qkad129. doi:10.1093/jrsssb/qkad129.
Examples
## Load libraries
library(abima)
set.seed(2)
## Set up parameters
M.family <- poisson()
simulation <- function(alpha_S = 0, beta_M = 0) {
data <- generate_all_data(
n = 500,
alpha_S = alpha_S,
beta_M = beta_M,
M.family = M.family
)
S <- data$S
M <- data$M
Y <- data$Y
X <- data$X
out <- abYlm.Mglm(S,
M,
Y,
X,
M.family = M.family,
lambda = 2,
B = 199)
out
}
simulation(1 / 8, 1 / 8)
simulation(0, 0)
Adaptive Bootstrap Test in Mediation Analysis with Linear Models
Description
abYlm.Mlm
performs an adaptive bootstrap test in mediation analysis in which both mediator M and outcome Y are modeled by linear models. The mediators can be multi-dimensional.
Usage
abYlm.Mlm(S, M, Y, X = NULL, s = 1, s_star = 0, B = 199, lambda = 2)
Arguments
S |
an n-by-1 vector for exposure. |
M |
an n-by-m matrix for m mediators, where each row corresponds to a m-element vector of mediators for one subject. The dimension m can be 1 or an integer larger than 1. |
Y |
an n-by-1 vector for outcome. |
X |
an n-by-p matrix for p confounders. Do not include intercept in matrix X. In the absence of confounders, matrix is not required to be specified. |
s |
exposure level with default set at 1. |
s_star |
baseline exposure level with default set at 0. |
B |
the number of bootstrap samples with default set at 199. |
lambda |
the tuning parameter used in the adaptive bootstrap procedure with default set at 2. |
Value
NIE refers to natural indirect effect, which is the estimated when a change of exposure S occurs from s_star to s.
p_value_NIE refers to the AB p value for NIE.
NDE refers to natural direct effect, which is estimated when exposure S changes from s_star to s.
p_value_NDE is the p value for NDE.
NTE is the estimated natural total effect when exposure S changes from s_star to s.
p_value_NTE is the p value for NTE.
References
He, Y., Song, P. X. K., and Xu, G. (2023), “Adaptive bootstrap tests for composite null hypotheses in the mediation pathway analysis,” Journal of the Royal Statistical Society Series B: Statistical Methodology, qkad129. doi:10.1093/jrsssb/qkad129.
Examples
## Load libraries
library(abima)
set.seed(2)
## Set up parameters
M.family <- gaussian()
Y.family <- gaussian()
simulation <- function(alpha_S = 0, beta_M = 0) {
data <- generate_all_data(
n = 200,
alpha_S = alpha_S,
beta_M = beta_M,
M.family = M.family,
Y.family = Y.family
)
S <- data$S
M <- data$M
Y <- data$Y
X <- data$X
out <- abYlm.Mlm(S, M, Y, X, lambda = 2, B = 199)
out
}
simulation(1 / 8, 1 / 8)
simulation(0, 0)
Data simulated from a directed acyclic graph (DAG) model
Description
Simulate data from a directed acyclic graph (DAG) model.
Usage
generate_all_data(
n = 200,
alpha_S = 0,
beta_M = 0,
tau_S = 1,
alpha_vec = rep(1, 3),
beta_vec = rep(1, 3),
M.family = stats::gaussian(),
Y.family = stats::gaussian(),
sigma_M = 0.5,
sigma_Y = 0.5
)
Arguments
n |
a sample size |
alpha_S |
a parameter in mediator model M~S+X for S |
beta_M |
a parameter in outcome model Y~S+M+X for M |
tau_S |
a parameter in outcome model Y~S+M+X for S |
alpha_vec |
a parameter vector in mediator model M~S+X for X |
beta_vec |
a parameter vector in outcome model Y~S+M+X for X |
M.family |
an error distribution and link function to be used in the mediator model. See |
Y.family |
an error distribution and link function to be used in the outcome model. See |
sigma_M |
the variance of the error term in the mediator model M~S+X |
sigma_Y |
the variance of the error term in the outcome model Y~S+M+X |
Value
A list with the following components:
S |
exposure |
M |
mediator |
Y |
outcome |
X |
confounder |
Examples
out <- generate_all_data(n = 200)
summary(out$S)
summary(out$M)
summary(out$Y)
summary(out$X)