Package 'mzipmed'

Title: Mediation using MZIP Model
Description: We implement functions allowing for mediation analysis to be performed in cases where the mediator is a count variable with excess zeroes. First a function is provided allowing users to perform analysis for zero-inflated count variables using the marginalized zero-inflated Poisson (MZIP) model (Long et al. 2014 <DOI:10.1002/sim.6293>). Using the counterfactual approach to mediation and MZIP we can obtain natural direct and indirect effects for the overall population. Using delta method processes variance estimation can be performed instantaneously. Alternatively, bootstrap standard errors can be used. We also provide functions for cases with exposure-mediator interactions with four-way decomposition of total effect.
Authors: Andrew Sims [aut, cre] , Dustin Long [aut], Hemant Tiwari [aut], Leann Long [aut]
Maintainer: Andrew Sims <[email protected]>
License: MIT + file LICENSE
Version: 1.4.0
Built: 2024-10-29 03:30:46 UTC
Source: https://github.com/ams329/mzipmed

Help Index


Mediation Analysis for Zero-Inflated Count Mediators using MZIP (Binary or Count Outcome)

Description

This function incorporates the MZIP model into the counterfactual approach to mediation analysis as proposed by Vanderweele when the mediator is a Zero-Inflated count variable for cases with binary or count outcome using a Poisson regression with robust standard errors. 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. A Poisson regression with robust standard errors were used to obtain direct and indirect effect estimates on a risk ratio scale because odds ratios are a non-collapsible measure which can cause issues in a mediation framework (see Vanderweele 2016). A logistic-regression can be specified for rare outcomes.

Usage

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

Arguments

outcome

is the binary or count outcome variable

mediator

is the zero-inflated 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)

C

is a vector for theoretical values of each confounder. By default each each value of C will be the mean value of each confounder.

n

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

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

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 mediator model. Note: Mediator/Offset is used in the outcome model

rare

set to TRUE of the outcome is rare and a logistic-regression should be used instead. Default is FALSE using robust Poisson model

OFF

is an offset is specified a fixed value of the offset variable is required for computation of effects. By default the mean is used.

Value

The function will return a list of 12 elements. GLM is the results of regressing the mediator+exposure+confounder on the outcome using a Poisson model with robust standard errors
MZIP is the results of regressing the exposure and confounders on the mediator using the MZIP model
RRNDE is the risk ratio of the direct effect
RRNIE is the risk ratio of the indirect effect.
logRRNDEse is the standard error for the log risk ratio of NDE
RRNDEci is the 95% confidence interval for the direct effect risk ratio
logRRNIEse is the standard error for the indirect effect log risk ratio
RRNIEci is the 95% confidence interval for the indirect effect risk ratio
RRTE is the total effect risk ratio
logRRTEse is the standard error for the total effect log risk ratio
RRTECI is the confidence interval for the total effect risk ratio
PM is the proportion mediated

Examples

#Example with delta method
    zimed=binoutzimed(outcome=mzipmed_data$binY,mediator=mzipmed_data$ziM,
                     exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                     mzipmed_data$C2),error="Delta",robust=FALSE,X=1,Xstar=0,
                     zioff=NULL,OFF=NULL,rare=FALSE)

    #Example using bootstrapping, 10 iterations are used for succinctness
    zimed2=binoutzimed(outcome=mzipmed_data$binY,mediator=mzipmed_data$ziM,
                   exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                   mzipmed_data$C2),error="Boot",n=10,C=c(0,0.5))

Mediation Analysis for Zero-Inflated Count Mediators using MZIP with Exposure-Mediator Interactions (Binary/Count Outcome)

Description

This function will do the same thing as the binoutzimed function, but includes an exposure-mediator interaction. 4-way decomposition of total effect (Vanderweele) are included in the output.

Usage

binoutzimedint(
  outcome,
  mediator,
  exposure,
  confounder = NULL,
  C = NULL,
  n = 1000,
  X = 1,
  Xstar = 0,
  M = NULL,
  error = "Delta",
  robust = FALSE,
  zioff = NULL,
  rare = FALSE,
  OFF = NULL
)

Arguments

outcome

is the continuous outcome variable

mediator

is the zero-inflated 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)

C

is a vector for theoretical values of each confounder. If left out the default will be set to the mean of each confounder giving marginal effects

n

is the number of repetitions for bootstrapping. Default is 1000. Setting n when using delta method errors will have no effect on output.

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.

M

is a fixed value for the mediator, M. If M is not specified, M will be set to its mean value

error

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

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 mediator model. Note: Mediator/Offset is used in the outcome model

rare

set to TRUE of the outcome is rare and a logistic-regression should be used instead. Default is FALSE using robust Poisson model

OFF

if an offset is specified a fixed value of the offset variable is required for derviation of effects. By default the mean is used.

Value

The function will return a list of 34 elements. GLM is the results of regressing the mediator+exposure+confounder on the outcome using a Poisson model with robust standard errors. To assess interaction effect individually look in the glm statement at the 4th parameter estimate
MZIP is the results of regressing the exposure and confounders on the mediator using the MZIP model
RRCDE is the controlled direct effect risk ratio
RRNDE is the natural direct effect risk ratio
RRNIE is the indirect effect risk ratio.
PM is the proportion mediated
logRRCDEse is the standard error for the controlled direct effect log risk ratio
RRCDEci is the 95% confidence interval for the controlled direct effect risk raito
logRRNDEse is the standard error for the natural direct effect log risk ratio
RRNDEci is the 95% confidence interval for the natural direct effect risk ratio
logRRNIEse is the standard error for the indirect effect log risk ratio
RRNIEci is the 95% confidence interval for the indirect effect risk ratio
Intref is the Interactive Reference effect (not a risk ratio)
Intrefse is the standard error for Intref
IntrefCI is the CI for Intref
RRPIE is the pure indirect effect risk ratio
logRRPIEse is the standard error of PIE log risk ratio
RRPIECI is the CI for PIE risk ratio
Intmed is the interactive mediation effect (not a risk ratio)
Intmedse is the error associated with Intmed
IntmedCI is the CI for Intmed
RRTE is the total effect risk ratio
logRRTEse is the error of the total effect log risk ratio
RRTECI is the CI for the total effect risk ratio
Int is the overall additive interaction effect
Intse is the standard error for the additive interaction
IntCI is the confidence interval for the interaction effect
PAINT is the proportion attributable to the interaction effect
PE is the proportion eliminated
PACDE is the proportion of the total effect due to neither mediation nor interaction
PAIntref is the proportion of the total effect due to just interaction
PAIntmed is the proportion of the total effect attributable to the joint effect of mediation and interaction
PAPIE is the proportion of the total effect attributable to just mediation
terr is the total excess relative risk

Examples

#Example with exposure-mediator interaction
   #This builds upon function without interaction
    zimmed=binoutzimedint(outcome=mzipmed_data$binY,mediator=mzipmed_data$ziM,
                   exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                   mzipmed_data$C2),error="Delta",robust=FALSE,X=1,Xstar=0,M=NULL,
                   C=NULL,zioff=NULL,OFF=NULL,rare=FALSE)

Mediation Analysis for Zero-Inflated Count Mediators using MZIP (Continuous Outcome)

Description

This function incorporates the MZIP model into the counterfactual approach to mediation analysis as proposed by Vanderweele when the mediator is a Zero-Inflated count variable. Errors for direct and indirect effects are computed using delta method or bootstrap. Note: This function assumes that the outcome is continuous and all exposure, mediator, outcome, and covariates have the same sample size. Binary variables must be dummy coded prior.

Usage

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

Arguments

outcome

is the continuous outcome variable

mediator

is the zero-inflated mediator variable, currently only 1 mediator 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)

C

is a vector for theoretical values of each confounder. By default each each value of C will be the mean value of each confounder.

n

is the number of repetition if bootstrapped errors are used

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

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 mediator model. Note: Mediator/Offset is used in the outcome model

Value

The function will return a list of 12 elements. LM is the results of regressing the mediator+exposure+confounder on the outcome using a linear model
MZIP is the results of regressing the exposure and confounders on the mediator using the MZIP model
NDE is the direct effect
NIE is the indirect effect.
NDEse is the standard error for the direct effect
NDEci is the 95% confidence interval for the direct effect
NIEse is the standard error for the indirect effect
NIEci is the 95% confidence interval for the indirect effect
TE is the total effect
TEse is the standard error for the total effect
TECI is the confidence interval for the total effect
PM is the proportion mediated

Examples

#Example with delta method
    zimed=lmoutzimed(outcome=mzipmed_data$lmY,mediator=mzipmed_data$ziM,
                 exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                 mzipmed_data$C2),error="Delta",robust=FALSE,X=1,Xstar=0,zioff=NULL)

    #Example using bootstrapping, 10 iterations used for succinctness
    zimed2=lmoutzimed(outcome=mzipmed_data$lmY,mediator=mzipmed_data$ziM,
                  exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                   mzipmed_data$C2),error="Boot",n=10,C=c(0,0.5))

Mediation Analysis for Zero-Inflated Count Mediators using MZIP with Exposure-Mediator Interactions (Continuous Outcome)

Description

This function will do the same thing as the lmoutzimed function, but includes an exposure-mediator interaction. 4-way decomposition of total effect (Vanderweele) are included in the output.

Usage

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

Arguments

outcome

is the continuous outcome variable

mediator

is the zero-inflated 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)

C

is a vector for theoretical values of each confounder. If left out the default will be set to the mean of each confounder giving marginal effects

n

is the number of repetitions for bootstrapping. Default is 1000. Setting n when using delta method errors will have no effect on output.

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.

M

is a fixed value for the mediator, M. If M is not specified, M will be set to its mean value

error

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

robust

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

zioff

(optional) used to specify an offset variable within the MZIP mediator model. Note: Mediator/Offset is used in the outcome model

OFF

if an offset is specified a fixed value of the offset is required to compute CDE. By default it is the mean of the offset or 1 if no offset is specified.

Value

The function will return a list of 30 elements. LM is the results of regressing the mediator+exposure+confounder on the outcome using a linear model. To assess interaction effect individually look in the lm statement at the 4th parameter estimate
MZIP is the results of regressing the exposure and confounders on the mediator using the MZIP model
CDE is the controlled direct effect
NDE is the natural direct effect
NIE is the indirect effect.
PM is the proportion mediated
CDEse is the standard error for the controlled direct effect
CDEci is the 95% confidence interval for the controlled direct effect
NDEste is the standard error for the natural direct effect
NDEci is the 95% confidence interval for the natural direct effect
NIEse is the standard error for the indirect effect
NIEci is the 95% confidence interval for the indirect effect
Intref is the Interactive Reference effect
Intrefse is the standard error for Intref
IntrefCI is the CI for Intref
PIE is the pure indirect effect
PIEse is the standard error of PIE
PIECI is the CI for PIE
Intmed is the interactive mediation effect
Intmedse is the error associated with Intmed
IntmedCI is the CI for Intmed
TE is the total effect
TEse is the error of the total effect
TECI is the CI for the total effect
Int is the overall additive interaction effect
Intse is the standard error for the additive interaction
IntCI is the confidence interval for the interaction effect
PAINT is the proportion attributable to the interaction effect
PE is the proportion eliminated

Examples

#Example with exposure-mediator interaction
   #This builds upon function without interaction
    zimmed=lmoutzimedint(outcome=mzipmed_data$lmY,mediator=mzipmed_data$ziM,
                  exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                  mzipmed_data$C2),error="Delta",robust=FALSE,X=1,Xstar=0,M=NULL,
                  C=NULL,zioff=NULL,OFF=NULL)

Marginalized Zero-Inflated Poisson Regression Model

Description

This function uses the MZIP model to allow you to fit counts variables with excess zeroes while allowing for easy interpretations. This function assumes that the outcome and covariates are all the same sample size without missing data. Covariates must be numerical, so binary predictors such as gender or race need to be dummy coded with zeroes and ones. For more information about this model and interpretations see Long, D Leann et al. "A marginalized zero-inflated Poisson regression model with overall exposure effects." Statistics in medicine vol. 33,29 (2014): 5151-65. doi:10.1002/sim.6293. Note: BFGS likelihood optimization was used for this R package. For more information on use of the offset argument see vignette.

Usage

mzip(y, pred, print = TRUE, offset = NULL)

Arguments

y

is the outcome variable

pred

is a vector of covariates (use cbind for multiple)

print

if =TRUE will give model parameters estimates and overall mean relative risks. Default =TRUE

offset

is an optional variable to be used as an offset, no need to log-transform prior

Value

The function will return a list of results from the MZIP model. In the list G(Gamma) refers to the excess zero/logistic part of the model
and A(Alpha) refers to the Poisson/mean part of the model for example.
Gest are the gamma coefficients for the logistic part of the MZIP model.
Aest are the alpha coefficients for the Poisson part of the MZIP model.
_ModelSE are the standard errors for each coefficient in the model.
_RobustSE are the robust standard errors for each coefficient in the model.
_ModelUpper are the upper confidence limits for each coefficient.
_ModelLower are the lower confidence limits.
_RobustUpper are the upper confidence limits based on robust standard error.
_RobustLower are the lower confidence limits based on robust standard errors.
_ModelZ are the Z scores for each coefficient.
_RobustZ are the robust Z scores for each coefficient.
_ModelZpval are the p-values based on the Z scores for the model.
_RobustZpval are the p-values based on the robust z scores.
AlphaCov is the covariance matrix for the poisson coefficient estimates
Cov is the covariance matrix for the MZIP model
RobAlphaCov robust covariance matrix for the Poisson component of MZIP
RobCov robust covariance matrix
loglik is the log-likelihood of the MZIP model
AIC is the Akaike's Information Criterion of the MZIP Model
BIC is the Bayesian's Information Criterion of the MZIP Model

Examples

test=mzip(y=mzipmed_data$ziY1,pred=cbind(mzipmed_data$X,mzipmed_data$C1,
              mzipmed_data$C2),print=FALSE,offset=NULL)

   ## Not run: 
   test= mzip(y=mzipmed_data$ziY1,pred=cbind(X=mzipmed_data$X,C1=mzipmed_data$C1,
              C2=mzipmed_data$C2),print=TRUE,offset=NULL)
              
## End(Not run)

Data to be used in the mzipmed package examples

Description

Data to be used in the mzipmed package examples

Usage

mzipmed_data

Format

A dataframe with 500 rows and 10 variables.

X

Simulated binary exposure ~Bernoulli(0.5)

C1

Simulated covariate ~Normal(0,1)

C2

Simulated covariate ~Beta(2,2)

ziM

Zero-inflated count mediator based on X,C1,C2

lmM

Continuous mediator based on X,C1,C2 with error term ~Normal(0,4)

binM

Binary mediator based on X,C1,C2

lmY

Continuous outcome to be used for ziM

binY

Binary outcome to be used for ziM

ziY1

Zero-inflated count outcome to be used for lmM

ziY2

Zero-inflated count outcome to be used for binM

@source Simulated to serve as an example

@examples data(mzipmed_data)


Mediation Analysis for Zero-Inflated Count Outcomes using MZIP with binary mediators

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 binary mediators using a logistic regression mediator model. 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 how to use offset command zioff.

Usage

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

Arguments

outcome

is the zero-inflated count outcome variable

mediator

is the binary 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)

n

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

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.

C

is a vector for theoretical values of each confounder. If left out the default will be set to the mean of each confounder giving marginal effects

error

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

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.

Value

The function will return a list of 12 elements. GLM is the logistic 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

Examples

#Example using delta method
    ziout=zioutbinmed(outcome=mzipmed_data$ziY2,mediator=mzipmed_data$binM,
                   exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                   mzipmed_data$C2),error="Delta",robust=FALSE,X=1,Xstar=0,zioff=NULL)
## Not run: 
    #Example using bootstrapping with 10 iterations
    ziout2=zioutbinmed(outcome=mzipmed_data$ziY2,mediator=mzipmed_data$binM,
                   exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                   mzipmed_data$C2),error="Boot",n=10,C=c(0,0.5),zioff=NULL)
   
## End(Not run)

Mediation Analysis for Zero-Inflated Count Outcomes using MZIP with Exposure-Mediator Interactions (Binary Outcome)

Description

This function will do the same thing as the zioutbinmed function, but includes an exposure-mediator interaction. 4-way decomposition of total effect (Vanderweele) are included in the output.

Usage

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

Arguments

outcome

is the zero-inflated count outcome variable

mediator

is the binary 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)

n

is the number of repetitions for bootstrapping. Default is 1000. Setting n when using delta method errors will have no effect on output.

M

is a fixed value for the mediator, M. If M is not specified, M will be set to its mean value

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.

C

is a vector for theoretical values of each confounder. If left out the default will be set to the mean of each confounder giving marginal effects

error

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

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.

Value

The function will return a list of 34 elements. MZIP is the results of regressing the mediator+exposure+confounder on the outcome using MZIP. To assess interaction effect individually look in the glm statement at the 4th parameter estimate
GLM is the results of regressing the exposure and confounders on the mediator using logistic regression
RRCDE is the controlled direct effect incidence rate ratio
RRNDE is the natural direct effect incidence rate ratio
RRNIE is the indirect effect incidence rate ratio.
PM is the proportion mediated
logRRCDEse is the standard error for the controlled direct effect log rate ratio
RRCDEci is the 95% confidence interval for the controlled direct effect rate raito
logRRNDEse is the standard error for the natural direct effect log rate ratio
RRNDEci is the 95% confidence interval for the natural 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
Intref is the Interactive Reference effect (not a ratio)
Intrefse is the standard error for Intref
IntrefCI is the CI for Intref
RRPIE is the pure indirect effect incidence rate ratio
logRRPIEse is the standard error of PIE log rate ratio
RRPIECI is the CI for PIE rate ratio
Intmed is the interactive mediation effect (not a ratio)
Intmedse is the error associated with Intmed
IntmedCI is the CI for Intmed
RRTE is the total effect incidence rate ratio
logRRTEse is the error of the total effect log rate ratio
RRTECI is the CI for the total effect rate ratio
Int is the overall additive interaction effect
Intse is the standard error for the additive interaction
IntCI is the confidence interval for the interaction effect
PAINT is the proportion attributable to the interaction effect
PE is the proportion eliminated
PACDE is the proportion of the total effect due to neither mediation nor interaction
PAIntref is the proportion of the total effect due to just interaction
PAIntmed is the proportion of the total effect attributable to the joint effect of mediation and interaction
PAPIE is the proportion of the total effect attributable to just mediation
terr is the total excess relative risk

Examples

zimout=zioutbinmedint(outcome=mzipmed_data$ziY2,mediator=mzipmed_data$binM,
                   exposure=mzipmed_data$X,confounder=cbind(mzipmed_data$C1,
                   mzipmed_data$C2),error="Delta",robust=FALSE,X=1,Xstar=0,M=NULL,C=NULL,
                   zioff=NULL)

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
)

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.

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

Examples

#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)

Mediation Analysis for Zero-Inflated Count Outcomes using MZIP with Exposure-Mediator Interactions

Description

This function will do the same thing as the zioutlmmed function, but includes an exposure-mediator interaction. 4-way decomposition of total effect (Vanderweele) are included in the output.

Usage

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

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)

n

is the number of repetitions for bootstrapping. Default is 1000. Setting n when using delta method errors will have no effect on output.

M

is a fixed value for the mediator, M. If M is not specified, M will be set to its mean value

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.

C

is a vector for theoretical values of each confounder. If left out the default will be set to the mean of each confounder giving marginal effects

error

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

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.

Value

The function will return a list of 34 elements. MZIP is the results of regressing the mediator+exposure+confounder on the outcome using MZIP. To assess interaction effect individually look in the glm statement at the 4th parameter estimate
LM is the results of regressing the exposure and confounders on the mediator using linear regression
RRCDE is the controlled direct effect incidence rate ratio
RRNDE is the natural direct effect incidence rate ratio
RRNIE is the indirect effect incidence rate ratio.
PM is the proportion mediated
logRRCDEse is the standard error for the controlled direct effect log rate ratio
RRCDEci is the 95% confidence interval for the controlled direct effect rate raito
logRRNDEse is the standard error for the natural direct effect log rate ratio
RRNDEci is the 95% confidence interval for the natural 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
Intref is the Interactive Reference effect (not a ratio)
Intrefse is the standard error for Intref
IntrefCI is the CI for Intref
RRPIE is the pure indirect effect incidence rate ratio
logRRPIEse is the standard error of PIE log rate ratio
RRPIECI is the CI for PIE rate ratio
Intmed is the interactive mediation effect (not a ratio)
Intmedse is the error associated with Intmed
IntmedCI is the CI for Intmed
RRTE is the total effect incidence rate ratio
logRRTEse is the error of the total effect log rate ratio
RRTECI is the CI for the total effect rate ratio
Int is the overall additive interaction effect
Intse is the standard error for the additive interaction
IntCI is the confidence interval for the interaction effect
PAINT is the proportion attributable to the interaction effect
PE is the proportion eliminated
PACDE is the proportion of the total effect due to neither mediation nor interaction
PAIntref is the proportion of the total effect due to just interaction
PAIntmed is the proportion of the total effect attributable to the joint effect of mediation and interaction
PAPIE is the proportion of the total effect attributable to just mediation
terr is the total excess relative risk

Examples

zimout=zioutlmmedint(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,M=NULL,C=NULL,
             zioff=NULL)