Title: | Mediation Analysis for Zero-Inflated Mediators |
---|---|
Description: | A novel mediation analysis approach to address zero-inflated mediators containing true zeros and false zeros. See Jiang et al (2023) "A Novel Causal Mediation Analysis Approach for Zero-Inflated Mediators" <arXiv:2301.10064> for more details. |
Authors: | Meilin Jiang [aut, cre], Zhigang Li [aut] |
Maintainer: | Meilin Jiang <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 0.0.3 |
Built: | 2025-02-05 05:13:26 UTC |
Source: | https://github.com/meilinjiang/maze |
Generate data under zero-inflated mediation models and calculate the true effects
DataGen(distM, theta, K, num_Z = 0, n, B, x1, x2, zval = NULL, mval = 0)
DataGen(distM, theta, K, num_Z = 0, n, B, x1, x2, zval = NULL, mval = 0)
distM |
distribution of the mediator. One of ' |
theta |
vector of true parameter values |
K |
true number of component |
num_Z |
number of confounder variables |
n |
number of observations to generate |
B |
the upper bound value |
x1 |
the first value of independent variable of interest |
x2 |
the second value of independent variable of interest |
zval |
the value of confounders to be conditional on when calculating true effects |
mval |
the fixed value of mediator to be conditional on when calculating true CDE |
true_eff: a vector containing true effects (NIE1, NIE2, NIE, NDE, and CDE)
dat: a data frame containing variables:
X
: independent variable,
Mobs
: observed mediator values (with possibly false zeros)
M
: true mediator values,
Y
: outcome,
Z
: confounder variables (if any)
Meilin Jiang [email protected] and Zhigang Li [email protected]
betas.tr <- c(2, 0.12, -6.6, 6.3, -3.8, 0) delta.tr <- 1.1 alpha0_k.tr <- c(0.4, 1.1) alpha1_k.tr <- c(0.1, 0.5) alphas.tr <- rbind(alpha0_k.tr,alpha1_k.tr) xi0.tr <- -1.5 psi_km1.tr <- c(0.6) gammas.tr <- c(-1.8, 0.5) eta.tr <- 1 theta <- c(betas.tr, delta.tr, alphas.tr, xi0.tr, psi_km1.tr, gammas.tr, eta.tr) out <- DataGen(distM = 'zilonm', theta, K = 2, num_Z=0, n = 200, B = 20, x1 = 0, x2 = 1, zval = NULL, mval = 0) (true_eff <- out$true_eff) dat <- out$dat
betas.tr <- c(2, 0.12, -6.6, 6.3, -3.8, 0) delta.tr <- 1.1 alpha0_k.tr <- c(0.4, 1.1) alpha1_k.tr <- c(0.1, 0.5) alphas.tr <- rbind(alpha0_k.tr,alpha1_k.tr) xi0.tr <- -1.5 psi_km1.tr <- c(0.6) gammas.tr <- c(-1.8, 0.5) eta.tr <- 1 theta <- c(betas.tr, delta.tr, alphas.tr, xi0.tr, psi_km1.tr, gammas.tr, eta.tr) out <- DataGen(distM = 'zilonm', theta, K = 2, num_Z=0, n = 200, B = 20, x1 = 0, x2 = 1, zval = NULL, mval = 0) (true_eff <- out$true_eff) dat <- out$dat
A novel mediation modeling approach to address zero-inflated mediators containing true zeros and false zeros.
MAZE( data, distM = c("zilonm", "zinbm", "zipm"), K = 1, selection = "AIC", X, M, Y, Z = NULL, XMint = c(TRUE, FALSE), x1, x2, zval = NULL, mval = 0, B = 20, seed = 1, ncore = 1 )
MAZE( data, distM = c("zilonm", "zinbm", "zipm"), K = 1, selection = "AIC", X, M, Y, Z = NULL, XMint = c(TRUE, FALSE), x1, x2, zval = NULL, mval = 0, B = 20, seed = 1, ncore = 1 )
data |
a data frame containing variables: an independent variable |
distM |
a vector with choices of the distribution of mediator to try with. One or more of ' |
K |
a vector with choices of the number of component |
selection |
model selection criterion when more than one model (combination of different values in |
X |
name of the independent variable. Can be continuous or discrete |
M |
name of the mediator variable. Non-negative values |
Y |
name of the outcome variable. Continuous values |
Z |
name(s) of confounder variables (if any) |
XMint |
a logical vector of length 2 indicating whether to include the two exposure-mediator interaction terms between (i) |
x1 |
the first value of independent variable of interest |
x2 |
the second value of independent variable of interest |
zval |
a vector of value(s) of confounders to be conditional on when estimating effects |
mval |
the fixed value of mediator to be conditional on when estimating CDE |
B |
the upper bound value |
seed |
an optional seed number to control randomness |
ncore |
number of cores available for parallel computing |
For an independent variable , a zero-inflated mediator
and a continuous outcome variable
, the following regression equation is used to model the association between
and
:
Users can choose to include either one, both, or none of the two exposure-mediator interaction terms between (i) and
and (ii)
and
using the argument
XMint
.
For mediators, zero-inflated log-normal, zero-inflated negative binomial, and zero-inflated Poisson distributions are considered and can be specified through the argument distM
.
The indirect and direct effects (NIE1, NIE2, NIE, NDE, and CDE) are estimated for changing from
x1
to x2
. When confounders are present, the conditional effects are estimated given the fixed value zval
.
a list containing:
results_effects
: a data frame for the results of estimated effects (NIE1, NIE2, NIE, NDE, and CDE). '_cond' for conditional effects at zval
and '_avg' for average effects
results_parameters
: a data frame for the results of model parameters
selected_model_name
: a string for the distribution of and number of components
selected in the final mediation model
BIC
: a numeric value for the BIC of the final mediation model
AIC
: a numeric value for the AIC of the final mediation model
models
: a list with all fitted models
analysis2_out
: a list with output from analysis2()
function (used for internal check)
Meilin Jiang [email protected] and Zhigang Li [email protected]
data(zinb10) maze_out <- MAZE(data = zinb10, distM = c('zilonm', 'zinbm', 'zipm'), K = 1, selection = 'AIC', X = 'X', M = 'Mobs', Y = 'Y', Z = NULL, XMint = c(TRUE, FALSE), x1 = 0, x2 = 1, zval = NULL, mval = 0, B = 20, seed = 1) ## results of selected mediation model maze_out$results_effects # indirect and direct effects maze_out$selected_model_name # selected distribution of the mediator and number of components K maze_out$results_parameters # model parameters maze_out$BIC; maze_out$AIC # BIC and AIC of the selected mediation model
data(zinb10) maze_out <- MAZE(data = zinb10, distM = c('zilonm', 'zinbm', 'zipm'), K = 1, selection = 'AIC', X = 'X', M = 'Mobs', Y = 'Y', Z = NULL, XMint = c(TRUE, FALSE), x1 = 0, x2 = 1, zval = NULL, mval = 0, B = 20, seed = 1) ## results of selected mediation model maze_out$results_effects # indirect and direct effects maze_out$selected_model_name # selected distribution of the mediator and number of components K maze_out$results_parameters # model parameters maze_out$BIC; maze_out$AIC # BIC and AIC of the selected mediation model
An example dataset generated from the proposed model with a zero-inflated negative binomial mediator (K=1). The mediator contains 10% zero values in which half are false zeros.
data(zinb10)
data(zinb10)
An object of class 'data.frame'
with 100 rows and 3 variables:
independent variable, continuous data type
outcome, continuous data type
observed mediator values with possibly false zeros, count data type
data(zinb10) head(zinb10)
data(zinb10) head(zinb10)