Learn R Programming

mzipmed (version 1.4.0)

zioutlmmed: Mediation Analysis for Zero-Inflated Count Outcomes using MZIP

Description

This function incorporates the MZIP model into the counterfactual approach to mediation analysis as proposed by Vanderweele when the outcome is a Zero-Inflated count variable for cases with continuous mediators. Standard Errors for direct and indirect effects are computed using delta method or bootstrapping. Note: This function assumes that the outcome is continuous and all exposure, mediator, outcome, and confounder variables have the same sample size. Binary variables must be dummy coded prior. See vignette for information on use of the offset.

Usage

zioutlmmed(
  outcome,
  mediator,
  exposure,
  confounder = NULL,
  X = 1,
  Xstar = 0,
  error = "Delta",
  n = 1000,
  robust = FALSE,
  zioff = NULL
)

Value

The function will return a list of 12 elements. LM is the linear model regressing the exposure and covariates on the continuous mediator

MZIP is the results of regressing the exposure, covariates, and mediator on the outcome using the MZIP model

RRNDE is the incidence rate ratio of the direct effect

RRNIE is the incidence rate ratio of the indirect effect.

logRRNDEse is the standard error for the log rate ratio of NDE

RRNDEci is the 95% confidence interval for the direct effect rate ratio

logRRNIEse is the standard error for the indirect effect log rate ratio

RRNIEci is the 95% confidence interval for the indirect effect rate ratio

RRTE is the total effect rate ratio

logRRTEse is the standard error for the total effect log rate ratio

RRTECI is the confidence interval for the total effect rate ratio

PM is the proportion mediated

Arguments

outcome

is the zero-inflated count outcome variable

mediator

is the continuous mediator variable, currently only 1 mediator variable is allowed

exposure

is the primary exposure being considered, only 1 is allowed

confounder

is a vector of confounder variables. If no confounder variables are needed then confounder is set to NULL. If more than 1 confounder is being considered then use the cbind function, e.g. cbind(var1,var2)

X

is the theoretical value for the exposure variable to be set at. The default is to 1

Xstar

is the theoretical value for the exposure variable to be compared to X. The default is 0, so direct, indirect, and proportion mediated values will be for a 1 unit increase in the exposure variable.

error

='Delta' for delta method standard errors and ='Boot' for bootstrap. Default is delta method

n

is the number of repetition if bootstrapped errors are used. Default is 1000

robust

indicates if a robust covariance matrix should be used for MZIP in delta method derivations. Default is FALSE.

zioff

(optional) use to specify an offset variable within the MZIP outcome model.

Examples

Run this code
    #Example using delta method
    ziout=zioutlmmed(outcome=mzipmed_data$ziY1,mediator=mzipmed_data$lmM,
                 exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                 mzipmed_data$C2),error="Delta",robust=FALSE,X=1,Xstar=0,
                 zioff=NULL)

   #Example using boostrapping, 10 iterations used for succinctness
   ziout2=zioutlmmed(outcome=mzipmed_data$ziY1,mediator=mzipmed_data$lmM,
                 exposure=mzipmed_data$X, confounder=cbind(mzipmed_data$C1,
                 mzipmed_data$C2),error="Boot",n=10,zioff=NULL)

Run the code above in your browser using DataLab