Package 'maczic'

Title: Mediation Analysis for Count and Zero-Inflated Count Data
Description: Performs causal mediation analysis for count and zero-inflated count data without or with a post-treatment confounder; calculates power to detect prespecified causal mediation effects, direct effects, and total effects; performs sensitivity analysis when there is a treatment- induced mediator-outcome confounder as described by Cheng, J., Cheng, N.F., Guo, Z., Gregorich, S., Ismail, A.I., Gansky, S.A. (2018) <doi:10.1177/0962280216686131>. Implements Instrumental Variable (IV) method to estimate the controlled (natural) direct and mediation effects, and compute the bootstrap Confidence Intervals as described by Guo, Z., Small, D.S., Gansky, S.A., Cheng, J. (2018) <doi:10.1111/rssc.12233>. This software was made possible by Grant R03DE028410 from the National Institute of Dental and Craniofacial Research, a component of the National Institutes of Health.
Authors: Nancy Cheng, Zijian Guo, Jing Cheng
Maintainer: Nancy Cheng <[email protected]>
License: GPL (>= 2)
Version: 1.0.0
Built: 2024-11-14 05:45:15 UTC
Source: https://github.com/cran/maczic

Help Index


maczic: Mediation Analysis for Count and Zero-inflated Count Data.

Description

Performs causal mediation analysis for count and zero-inflated count data; calculates power of causal mediation effects, direct effects, total effects; implements Instrumental Variable (IV) method to estimate the controlled (natural) direct and mediation effect, and the bootstrap CIs; calculates power of controlled (natural) direct and mediation effect using IV method; performs sensitivity analysis when there is a treatment-induced mediator-outcome confounder by varing coefficient of treatment in the confounder model and plots sensitivity graph.


Power Calculation for Mediation Analysis with Count and Zero-Inflated Count Data

Description

'maczic_power' computes powers to detect average causal mediation effects (indirect effect), average direct effects, and total effect. This function uses simulations of 3 optional covariates (binary, normal, and multinomial), mediator (can be binary or continuous), and outcome (can be Normal, Poisson, Negative Binomial, zero-inflated Poisson/Negative Binomial) based on user-specified parameter values.

Usage

maczic_power(
  nsim,
  nsp,
  mtype,
  boot = FALSE,
  sims = 1000,
  conf.level = 0.95,
  ydist,
  size = 1,
  ymax,
  lpct0 = 0,
  hpct0 = 100,
  px1,
  am,
  bm,
  e1m,
  e2m,
  e3m,
  ag,
  bg,
  gg,
  e1g,
  e2g,
  e3g,
  delta = 0,
  ag2 = 0,
  bg2 = 0,
  gg2 = 0,
  e1g2 = 0,
  e2g2 = 0,
  e3g2 = 0,
  delta2 = 0,
  digits = 3
)

Arguments

nsim

Number of simulations.

nsp

Sample size.

mtype

Type of mediator, either 'binary' or 'continuous'.

boot

A logical value. if 'FALSE' a quasi-Bayesian approximation is used for confidence intervals; if 'TRUE' nonparametric bootstrap will be used. Default is 'FALSE'.

sims

Number of Monte Carlo draws for nonparametric bootstrap or quasi-Bayesian approximation. Default is 1000.

conf.level

Level of the returned two-sided confidence intervals. The default value, 0.95, is to return the 2.5 and 97.5 percentiles of the simulated quantities.

ydist

Outcome distribution. Can be 'poisson', 'negbin', 'zip', 'zinb', or 'normal'.

size

Dispersion parameter for negative binomial outcome distribution. Default is 1. It's ignored for other outcome distribution.

ymax

Maximum value of outcome allowed.

lpct0

Low bound for percent of zeros in outcome. Default is 0.

hpct0

High bound for percent of zeros in outcome. Default is 100.

px1

Probability of the binary covariate being 1.

am

User-specified value for the intercept in the mediator model.

bm

User-specified value for the treatment coefficient in the mediator model.

e1m

User-specified value for the coefficient of the binary covariate variable in the mediator model.

e2m

User-specified value for the coefficient of the continuous covariate variable in the mediator model.

e3m

User-specified value for the coefficient of the multinomial covariate variable in the mediator model.

ag

User-specified value for the intercept in the outcome model or in the count model of zero-inflated Poisson/Negative Binomial outcome.

bg

User-specified value for the treatment coefficient in the outcome model or in the count model of zero-inflated Poisson/Negative Binomial outcome.

gg

User-specified value for the mediator coefficient in the outcome model or in the count model of zero-inflated Poisson/Negative Binomial outcome.

e1g

User-specified value for the coefficient of the binary covariate variable in the outcome model or in the count model of zero-inflated Poisson/Negative Binomial outcome.

e2g

User-specified value for the coefficient of the continuous covariate variable in the outcome model or in the count model of zero-inflated Poisson/Negative Binomial outcome.

e3g

User-specified value for the coefficient of the multinomial covariate variable in the outcome model or in the count model of zero-inflated Poisson/Negative Binomial outcome.

delta

User-specified value for the treatment-by-mediator interaction coefficient in the outcome model or in the count model of zero-inflated Poisson/Negative Binomial outcome model. Default is 0.

ag2

User-specified value for the intercept in the zero-inflation model of zero-inflated Poisson/Negative Binomial outcome. Note that this argument along with the following argument bg2, gg2, e1g2, e2g2, e3g2 and delta2 only apply to zero-inflated Poisson/Negative Binomial outcome. Default is 0.

bg2

User-specified value for the treatment coefficient in the zero-inflation model of zero-inflated Poisson/Negative Binomial outcome. Default is 0.

gg2

User-specified value for the mediator coefficient in the zero-inflation model of zero-inflated Poisson/Negative Binomial outcome. Default is 0.

e1g2

User-specified value for the coefficient of the binary covariate variable in the zero-inflation model of zero-inflated Poisson/Negative Binomial outcome. Default is 0.

e2g2

User-specified value for the coefficient of the continuous covariate variable in the zero-inflation model of zero-inflated Poisson/Negative Binomial outcome. Default is 0.

e3g2

User-specified value for the coefficient of the multinomial covariate variable in the zero-inflation model of zero-inflated Poisson/Negative Binomial outcome. Default is 0.

delta2

User-specified value for the coefficient of treatment-by-mediator interaction in the zero-inflation model of zero-inflated Poisson/Negative Binomial outcome. Default is 0.

digits

Integer indicating the number of decimal places to round the values to be returned. Default is 3.

Value

maczic_power returns a data frame with the following components and prints them out in a matrix format:

te.d0, te.d1

average true mediation effects under the control and treatment conditions.

te.z0, te.z1

average true direct effects under the control and treatment conditions.

te.tau

average true total effect.

ee.d0.rej, ee.d1.rej

power to detect mediation effects under the control and treatment conditions.

ee.z0.rej, ee.z1.rej

power to detect direct effects under the control and treatment conditions.

ee.tau.rej

power to detect total effect.

mean.y.z0

mean outcome in control in the simulated data, not available if outcome is normal.

mean.y.z1

mean outcome in treatment in the simulated data, not available if outcome is normal.

mean.y.gt0.z0

mean non-zero outcome in control in the simulated data, not available if outcome is normal.

mean.y.gt0.z1

mean non-zero outcome in treatment in the simulated data, not available if outcome is normal

pct0.y.z0

mean percent zero outcome in control in the simulated data, not available if outcome is normal.

pct0.y.z1

mean percent zero outcome in treatment in the simulated data, not available if outcome is normal.

Author(s)

Nancy Cheng, [email protected]; Jing Cheng, [email protected].

References

Cheng, J., Cheng, N.F., Guo, Z., Gregorich, S., Ismail, A.I., Gansky, S.A (2018) Mediation analysis for count and zero-inflated count data. Statistical Methods in Medical Research. 27(9):2756-2774.

Tingley, D., Yamamoto, T., Hirose, K., Imai, K. and Keele, L. (2014). "mediation: R package for Causal Mediation Analysis", Journal of Statistical Software, Vol. 59, No. 5, pp. 1-38.

Imai, K., Keele, L., Tingley, D. and Yamamoto, T. (2011). Unpacking the Black Box of Causality: Learning about Causal Mechanisms from Experimental and Observational Studies, American Political Science Review, Vol. 105, No. 4 (November), pp. 765-789.

Imai, K., Keele, L. and Tingley, D. (2010) A General Approach to Causal Mediation Analysis, Psychological Methods, Vol. 15, No. 4 (December), pp. 309-334.

Imai, K., Keele, L. and Yamamoto, T. (2010) Identification, Inference, and Sensitivity Analysis for Causal Mediation Effects, Statistical Science, Vol. 25, No. 1 (February), pp. 51-71.

Imai, K., Keele, L., Tingley, D. and Yamamoto, T. (2009) "Causal Mediation Analysis Using R" in Advances in Social Science Research Using R, ed. H. D. Vinod New York: Springer.

See Also

mediate_zi

Examples

# For illustration purposes a small number of simulations are used
# Example 1: simulate Poisson outcome with sample size 100, binary mediator
# and 2 covariate (binary and normal) variables
posOut <- maczic_power(nsim = 8, nsp = 100,  mtype = 'binary',
                       sims = 40, ydist = "Poisson", ymax = 60,
                       px1 = 0.5, am = 0.2, bm = 0.5,
                       e1m = 0.1, e2m = 0.1, e3m = 0,
                       ag = 0.1, bg = 0.3, gg = 1,
                       e1g = 0.5, e2g = -0.2, e3g = 0, delta = 0.1)

# Example 2: simulate zero-inflated Poisson outcome with sample size 80,
# continuous mediator and 1 normal covariate variable
zipOut <-maczic_power(nsim = 5, nsp = 80, mtype = 'continuous',
                       sims=30, ydist = "zip", ymax = 88, hpct0 = 60,
                       px1 = 0.5, am = 0.1, bm = 1,
                       e1m = 0, e2m = 0.2, e3m = 0,
                       ag = 0.6, bg = 0.6, gg = 0.2, e1g = 0, e2g = -0.2,
                       e3g = 0, ag2 = -0.7, bg2 = 0.2, gg2 = 0.1,
                       e2g2 = 0.1, delta2 = 0.15)

Mediation Analysis for Count and Zero-Inflated Count Data Using Instrumental Variable Method

Description

'mediate_iv' is used to estimate controlled or natural direct effect ratio, indirect (mediation) effect ratio for count and zero-inflated count data using Instrumental Variable (IV) method described in Guo, Z., Small, D.S., Gansky, S.A., Cheng, J. (2018).

Usage

mediate_iv(
  y,
  z,
  m,
  zm.int = FALSE,
  ydist = "poisson",
  mtype = "binary",
  x.IV,
  x.nonIV = NULL,
  tol = 1e-05,
  n.init = 3,
  control = list(),
  conf.level = 0.95,
  sims = 1000
)

Arguments

y

Outcome variable.

z

Treatment variable.

m

Mediator variable.

zm.int

A logical value. if 'FALSE' the interaction of treatment by mediator will not be included in the outcome model; if 'TRUE' the interaction will be included in the outcome model. Default is 'FALSE'.

ydist

A character string indicating outcome distribution which will be used to fit for getting the initial parameter estimates. Can only take one of the these three values - 'poisson', 'negbin', or 'neyman type a' Default is 'poisson'. Use 'neyman type a' for zero-inflated outcomes.

mtype

A character string indicating mediator type, either 'binary' or 'continuous'. Default is 'binary'.

x.IV

Specifies baseline variable(s) to construct Instrumental Variable(s), Use cbind() for 2 or more IVs.

x.nonIV

Specifies baseline variable(s) that are not used to construct Instrumental Variable(s) as covariates. Use cbind() for 2 or more non IVs. Default is NULL.

tol

Numeric tolerance value for parameter convergence. When the square root of sum of squared difference between two consecutive set of optimized parameters less than tol, then the convergence is reached. Default is 1e-5.

n.init

Number of set of initial parameter values. Default is 3.

control

A list of parameters governing the nonlinear optimization algorithm behavior (to minimize the profile empirical log-likelihood). This list is the same as that for BBoptim(), which is a wrapper for spg(). control default is list(maxit = 1500, M = c(50, 10), ftol=1e-10, gtol = 1e-05, maxfeval = 10000, maximize = FALSE, trace = FALSE, triter = 10, eps = 1e-07, checkGrad=NULL). See spg for more details.

conf.level

Level of the returned two-sided bootstrap confidence intervals. The default value, 0.95, is to return the 2.5 and 97.5 percentiles of the simulated quantities.

sims

Number of Monte Carlo draws for nonparametric bootstrap. Default is 1000.

Details

'mediate_iv' is to estimate the controlled and natural direct and indirect ratios of randomized treatment around and through mediators when there is unmeasured confounding. This function considers count and zero-inflated count outcomes, and binary and continuous mediators. The estimation uses an instrumental variable approach with empirical likelihood and estimating equations, where no parametric assumption is needed for the outcome distribution.

Controlled effect ratio

Given the generalized linear model for the expected potential outcomes: \[f[E(Y(z,m)|x,u)] = \beta_0 + \beta_zz + \beta_mm + \beta_xx + u,\] where \(f\) is a log-link function, \(\beta_0\) is the intercept, \(z\) is the treatment, \(m\) is pre-specified mediator value, \(x\) are baseline covariates, \(\beta_z\), \(\beta_m\), \(\beta_x\) are their corresponding coefficients, \(u\) are unmeasured confounders and \(Y(z,m)\) is the potential outcome under treatment \(z\) and mediator \(m\). Then the controlled direct effect ratio when the treatment changes from \(z^\ast\) to \(z\) while keeping the mediator at \(m\):

\[\frac{E[Y(z,m)|x,u]}{E[Y(z^\ast,m)|x,u]} = \exp[\beta_z(z-z^\ast)]\]

and the controlled indirect effect ratio when the mediator changes from \(m^\ast\) to \(m\) while keeping the treatment at \(z\): \[\frac{E[Y(z,m)|x,u]}{E[Y(z,m^\ast)|x,u]} = \exp[\beta_m(m-m^\ast)]\]

Natural effect ratio

Given a generalized linear model for the expected potential outcomes and a model for the mediator: \[f[E(Y(z,M^{z^\ast}|x,u))] = \beta_0 + \beta_zz + \beta_mM^{z^\ast} + \beta_xx + u,\] where \(f\) is a log-link function, \(M^{z^\ast}\) is the potential mediator under treatment \(z^\ast\), and \(Y(z,M^{z^\ast})\) is the potential outcome under treatment \(z\) and potential mediator \(M^{z^\ast}\) \[h[E(M^{z^\ast}|x,u)] = \alpha_0 + \alpha_zz^\ast + \alpha_xx + \alpha_{IV}z^\ast x^{IV} + u,\] where \(h\) is an identity function for continuous mediators and logit function for binary mediators; \(\alpha_{IV}\) is the coefficient for instrumental variables \(x^{IV}\), \(z^\ast x^{IV}\), interaction of randomized treatment and instrumental variables, and \(M^z\) is the potential mediator under treatment \(z^\ast\). Then the natural direct effect ratio is: \[\frac{E[Y(z,M^{z^\ast})|x,u]}{E[Y(z^\ast,M^{z^\ast}|x,u]} = \exp[\beta_z(z-z^\ast)].\] And the natural indirect effect ratio with a continuous mediator is: \[\frac{E[Y(z,M^z)|x,u]}{E[Y(z,M^{z^\ast})|x,u]} = \exp[\beta_m\alpha_z(z-z^\ast) + \beta_m\alpha_{IV}x^{IV}(z-z^\ast)].\] The natural indirect effect ratio with a binary mediator is: \[\frac{E[Y(z,M^z)|x,u]}{E[Y(z,M^{z^\ast})|x,u]} = \frac{P(M^z = 1|x,u)\exp(\beta_m) + P(M^z = 0|x, u)} {P(M^{z^\ast} = 1|x,u) \exp(\beta_m) + P(M^{z^\ast} = 0|x, u)}. \]

The parameters are estimated by the maximized empirical likelihood estimates, which are solutions to the estimating equations that maximizes the empirical likelihood. See details in Guo, Z., Small, D.S., Gansky, S.A., Cheng, J. (2018).

Value

mediate_iv returns a list with the following components and prints them out in a matrix format:

beta

parameter estimates from optimized profile empirical log-likelihood.

ter, ter.ci

point estimate for total effect ratio and its bootstrap confidence interval.

If the interaction between treatment and mediator is not specified, ie, zm.int=FALSE, a list of additional components are:

der, der.ci

point estimate for controlled direct effect ratio and its bootstrap confidence interval.

der.nat, der.nat.ci

point estimate for natural direct effect ratio and its bootstrap confidence interval.

ier, ier.ci

point estimate for controlled indirect effect ratio and its bootstrap confidence interval.

ier.nat, ier.nat.ci

point estimate for natural indirect effect ratio and its bootstrap confidence interval; They are only applicable to continuous mediator.

If the interaction between treatment and mediator is specified, ie, zm.int=TRUE, which is only supported for binary mediator, a list of additional components are:

der.m0, der.m0.ci

point estimate for controlled direct effect ratio when m = 0 and its bootstrap confidence interval.

der.m1, der.m1.ci

point estimate for controlled direct effect ratio when m = 1 and its bootstrap confidence interval.

der.nat.m0, der.nat.m0.ci

point estimate for natural direct effect ratio when m = 0 and its bootstrap confidence interval.

der.nat.m1, der.nat.m1.ci

point estimate for natural direct effect ratio when m = 1 and its bootstrap confidence interval.

ier.z0, ier.z0.ci

point estimate for controlled indirect effect ratio when z = 0 and its bootstrap confidence interval.

ier.z1, ier.z1.ci

point estimate for controlled indirect effect ratio when z = 1 and its bootstrap confidence interval.

Author(s)

Nancy Cheng, [email protected]; Zijian Guo, [email protected]; Jing Cheng, [email protected].

References

Guo, Z., Small, D.S., Gansky, S.A., Cheng, J. (2018), Mediation analysis for count and zero-inflated count data without sequential ignorability and its application in dental studies. Journal of the Royal Statistical Society, Series C.; 67(2):371-394.

Ismail AI, Ondersma S, Willem Jedele JM, et al. (2011) Evaluation of a brief tailored motivational intervention to prevent early childhood caries. Community Dentistry and Oral Epidemiology 39: 433–448.

See Also

el.test, BBoptim, spg

Examples

# For illustration purposes a small number of bootstrap iterations are used
data("midvd_bt100")
# The outcome is Poisson distribution
ee <- mediate_iv(y = midvd_bt100$Untreated_W3,
                 z = midvd_bt100$intervention,
                 m = midvd_bt100$PBrush_6, ydist = "poisson",
                 mtype = "binary", x.IV = midvd_bt100$BrushTimes_W2,
                 tol = 0.5, n.init = 1,
                 control = list(maxit = 15, ftol = 0.5, gtol = 0.5,
                                trace = FALSE),
                 sims = 3)

Mediation Analysis for Count and Zero-Inflated Count Data

Description

'mediate_zi' is modified from the mediate function in mediation package (version 4.0.1) with the new feature added to handle Zero-inflated count outcomes including Zero-inflated Poisson and Zero-inflated Negative Binomial outcomes. This function is used to estimate various quantities for causal mediation analysis, including average causal mediation effects (ACME) or indirect effect, average direct effects (ADE), proportions mediated, and total effect. The Usage, Argument, Value, and Details of this function are the same as mediate() in mediation package version 4.0.1 (see below) except for the description of the 'model.y' argument, which has class 'zeroinfl' added.

Usage

mediate_zi(
  model.m,
  model.y,
  sims = 1000,
  boot = FALSE,
  treat = "treat.name",
  mediator = "med.name",
  covariates = NULL,
  outcome = NULL,
  control = NULL,
  conf.level = 0.95,
  control.value = 0,
  treat.value = 1,
  long = TRUE,
  dropobs = FALSE,
  robustSE = FALSE,
  cluster = NULL,
  ...
)

Arguments

model.m

A fitted model object for mediator. Can be of class 'lm', 'polr', 'bayespolr', 'glm', 'bayesglm', 'gam', 'rq', or 'survreg'.

model.y

A fitted model object for outcome. Can be of class 'lm', 'polr', 'bayespolr', 'glm', 'bayesglm', 'gam', 'vglm', 'rq', 'survreg', or 'zeroinfl'

sims

Number of Monte Carlo draws for nonparametric bootstrap or quasi-Bayesian approximation.

boot

A logical value. if 'FALSE' a quasi-Bayesian approximation is used for confidence intervals; if 'TRUE' nonparametric bootstrap will be used. Default is 'FALSE'.

treat

A character string indicating the name of the treatment variable used in the models. The treatment can be either binary (integer or a two-valued factor) or continuous (numeric).

mediator

A character string indicating the name of the mediator variable used in the models.

covariates

A list or data frame containing values for a subset of the pre-treatment covariates in 'model.m' and 'model.y'. If provided, the function will return the estimates conditional on those covariate values.

outcome

A character string indicating the name of the outcome variable in ‘model.y’. Only necessary if 'model.y' is of class 'survreg'; otherwise ignored.

control

A character string indicating the name of the control group indicator. Only relevant if 'model.y' is of class 'gam'. If provided, 'd0', 'z0' and 'n0' are allowed to differ from 'd1', 'z1' and 'n1', respectively.

conf.level

Level of the returned two-sided confidence intervals. Default is to return the 2.5 and 97.5 percentiles of the simulated quantities.

control.value

Value of the treatment variable used as the control condition. Default is 0.

treat.value

Value of the treatment variable used as the treatment condition. Default is 1.

long

A logical value. If 'TRUE', the output will contain the entire sets of simulation draws of the the average causal mediation effects, direct effects, proportions mediated, and total effect. Default is 'TRUE'.

dropobs

A logical value indicating the behavior when the model frames of 'model.m' and 'model.y' (and the 'cluster' variable if included) are composed of different observations. If 'TRUE', models will be re-fitted using common data rows. If 'FALSE', error is returned. Default is 'FALSE'.

robustSE

A logical value. If 'TRUE', heteroskedasticity-consistent standard errors will be used in quasi-Bayesian simulations. Ignored if 'boot' is 'TRUE' or neither 'model.m' nor 'model.y' has a method for vcovHC in the sandwich package. Default is 'FALSE'.

cluster

A variable indicating clusters for standard errors. Note that this should be a vector of cluster indicators itself, not a character string for the name of the variable.

...

other arguments passed to vcovHC in the sandwich package: typically the 'type' argument, which is ignored if 'robustSE' is 'FALSE'. Arguments to the boot in the boot package may also be passed, e.g. 'parallel' and 'ncpus'.

Details

This is the workhorse function for estimating causal mediation effects for a variety of data types. The average causal mediation effect (ACME) represents the expected difference in the potential outcome when the mediator took the value that would realize under the treatment condition as opposed to the control condition, while the treatment status itself is held constant. That is, \[\delta(t) \ = \ E[Y(t, M(t_1)) - Y(t, M(t_0))],\] where \(t, t_1, t_0\) are particular values of the treatment \(T\) such that \(t_1 \neq t_0\), \(M(t)\) is the potential mediator, and \(Y(t,m)\) is the potential outcome variable. The average direct effect (ADE) is defined similarly as, \[\zeta(t) \ = \ E[Y(t_1, M(t)) - Y(t_0, M(t))],\] which represents the expected difference in the potential outcome when the treatment is changed but the mediator is held constant at the value that would realize if the treatment equals \(t\). The two quantities on average add up to the total effect of the treatment on the outcome, \(\tau\). See the references for more details.

When both the mediator model ('model.m') and outcome model ('model.y') are normal linear regressions, the results will be identical to the usual LSEM method by Baron and Kenny (1986). The function can, however, accommodate other data types including binary, ordered and count outcomes and mediators as well as censored outcomes. Variables can also be modeled nonparametrically, semiparametrically, or using quantile regression.

If it is desired that inference be made conditional on specific values of the pre-treatment covariates included in the model, the ‘covariates’ argument can be used to set those values as a list or data frame. The list may contain either the entire set or any strict subset of the covariates in the model; in the latter case, the effects will be averaged over the other covariates. The ‘covariates’ argument will be particularly useful when the models contain interactions between the covariates and the treatment and/or mediator (known as “moderated mediation”).

The prior weights in the mediator and outcome models are taken as sampling weights and the estimated effects will be weighted averages when non-NULL weights are used in fitting 'model.m' and 'model.y'. This will be useful when data does not come from a simple random sample, for example.

As of version 4.0, the mediator model can be of either 'lm', 'glm' (or ‘bayesglm’), 'polr' (or ‘bayespolr’), 'gam', 'rq', or ‘survreg’ class corresponding respectively to the linear regression models, generalized linear models, ordered response models, generalized additive models, quantile regression models, or parametric duration models. For binary response models, the 'mediator' must be a numeric variable with values 0 or 1 as opposed to a factor. Quasi-likelihood-based inferences are not allowed for the mediator model because the functional form must be exactly specified for the estimation algorithm to work. The 'binomial' family can only be used for binary response mediators and cannot be used for multiple-trial responses. This is due to conflicts between how the latter type of models are implemented in glm and how 'mediate' is currently written.

For the outcome model, the censored regression model fitted via package VGAM (of class 'vglm' with 'family@vfamily' equal to "tobit") can be used in addition to the models listed above for the mediator. The 'mediate' function is not compatible with censored regression models fitted via other packages. When the quantile regression is used for the outcome model ('rq'), the estimated quantities are quantile causal mediation effects, quantile direct effects and etc., instead of the average effects. If the outcome model is of class 'survreg', the name of the outcome variable must be explicitly supplied in the ‘outcome’ argument. This is due to the fact that 'survreg' objects do not contain that information in an easily extractable form. It should also be noted that for survreg models, the Surv function must be directly used in the model formula in the call to the survreg function, and that censoring types requiring more than two arguments to Surv (e.g., interval censoring) are not currently supported by 'mediate'.

The quasi-Bayesian approximation (King et al. 2000) cannot be used if 'model.m' is of class 'rq' or 'gam', or if 'model.y' is of class 'gam', 'polr' or 'bayespolr'. In these cases, either an error message is returned or use of the nonparametric bootstrap is forced. Users should note that use of the nonparametric bootstrap often requires significant computing time, especially when 'sims' is set to a large value.

The 'control' argument must be provided when 'gam' is used for the outcome model and user wants to allow ACME and ADE to vary as functions of the treatment (i.e., to relax the "no interaction" assumption). Note that the outcome model must be fitted via package mgcv with appropriate formula using s constructs (see Imai et al. 2009 in the references). For other model types, the interaction can be allowed by including an interaction term between T and M in the linear predictor of the outcome model. As of version 3.0, the 'INT' argument is deprecated and the existence of the interaction term is automatically detected (except for 'gam' outcome models).

When the treatment variable is continuous or a factor with multiple levels, user must specify the values of \(t_1\) and \(t_0\) using the 'treat.value' and 'control.value' arguments, respectively. The value of \(t\) in the above expressions is set to \(t_0\) for 'd0', 'z0', etc. and to \(t_1\) for 'd1', 'z1', etc.

Value

mediate returns an object of class "mediate", (or "mediate.order" if the outcome model used is 'polr' or 'bayespolr'), a list that contains the components listed below. Some of these elements are not available if 'long' is set to 'FALSE' by the user.

The function summary (i.e., summary.mediate, or summary.mediate.order) can be used to obtain a table of the results. The function plot (i.e., plot.mediate, or plot.mediate.order) can be used to produce a plot of the estimated average causal mediation, average direct, and total effects along with their confidence intervals.

d0, d1

point estimates for average causal mediation effects under the control and treatment conditions.

d0.ci, d1.ci

confidence intervals for average causal mediation effects. The confidence level is set at the value specified in 'conf.level'.

d0.p, d1.p

two-sided p-values for average causal mediation effects.

d0.sims, d1.sims

vectors of length 'sims' containing simulation draws of average causal mediation effects.

z0, z1

point estimates for average direct effect under the control and treatment conditions.

z0.ci, z1.ci

confidence intervals for average direct effects.

z0.p, z1.p

two-sided p-values for average causal direct effects.

z0.sims, z1.sims

vectors of length 'sims' containing simulation draws of average direct effects.

n0, n1

the "proportions mediated", or the size of the average causal mediation effects relative to the total effect.

n0.ci, n1.ci

confidence intervals for the proportions mediated.

n0.p, n1.p

two-sided p-values for proportions mediated.

n0.sims, n1.sims

vectors of length 'sims' containing simulation draws of the proportions mediated.

tau.coef

point estimate for total effect.

tau.ci

confidence interval for total effect.

tau.p

two-sided p-values for total effect.

tau.sims

a vector of length 'sims' containing simulation draws of the total effect.

d.avg, z.avg, n.avg

simple averages of d0 and d1, z0 and z1, n0 and n1, respectively, which users may want to use as summary values when those quantities differ.

d.avg.ci, z.avg.ci, n.avg.ci

confidence intervals for the above.

d.avg.p, z.avg.p, n.avg.p

two-sided p-values for the above.

d.avg.sims, z.avg.sims, n.avg.sims

vectors of length 'sims' containing simulation draws of d.avg, z.avg and n.avg, respectively.

boot

logical, the 'boot' argument used. If 'FALSE' a quasi-Bayesian approximation was used for confidence intervals; if 'TRUE' nonparametric bootstrap was used

boot.ci.type

a character string 'perc' indicating percentile bootstrap confidence intervals were estimated if the argument boot = TRUE

treat

a character string indicating the name of the 'treat' variable used in the models

mediator

a character string indicating the name of the 'mediator' variable used in the models

INT

a logical value indicating whether the model specification allows the effects to differ between the treatment and control conditions.

conf.level

the confidence level used.

model.y

the outcome model used.

model.m

the mediator model used.

control.value

value of the treatment variable used as the control condition.

treat.value

value of the treatment variable used as the treatment condition.

nobs

number of observations in the model frame for 'model.m' and 'model.y'. May differ from the numbers in the original models input to 'mediate' if 'dropobs' was 'TRUE'.

robustSE

‘TRUE’ or ‘FALSE’.

cluster

the clusters used.

Author(s)

Nancy Cheng, [email protected]; Jing Cheng, [email protected].

References

Cheng, J., Cheng, N.F., Guo, Z., Gregorich, S., Ismail, A.I., Gansky, S.A (2018) Mediation analysis for count and zero-inflated count data. Statistical Methods in Medical Research. 27(9):2756-2774.

Tingley, D., Yamamoto, T., Hirose, K., Imai, K. and Keele, L. (2014). "mediation: R package for Causal Mediation Analysis", Journal of Statistical Software, Vol. 59, No. 5, pp. 1-38.

Imai, K., Keele, L., Tingley, D. and Yamamoto, T. (2011). Unpacking the Black Box of Causality: Learning about Causal Mechanisms from Experimental and Observational Studies, American Political Science Review, Vol. 105, No. 4 (November), pp. 765-789.

Imai, K., Keele, L. and Tingley, D. (2010) A General Approach to Causal Mediation Analysis, Psychological Methods, Vol. 15, No. 4 (December), pp. 309-334.

Imai, K., Keele, L. and Yamamoto, T. (2010) Identification, Inference, and Sensitivity Analysis for Causal Mediation Effects, Statistical Science, Vol. 25, No. 1 (February), pp. 51-71.

Imai, K., Keele, L., Tingley, D. and Yamamoto, T. (2009) "Causal Mediation Analysis Using R" in Advances in Social Science Research Using R, ed. H. D. Vinod New York: Springer.

See Also

summary.mediate, plot.mediate

Examples

# For illustration purposes a small number of simulations are used
# Example: Zero-inflated Count Outcome and Binary Mediator
# Generate example data
n <- 50
# Generate binary treatment variable
z <- rep(0, n)
z[sample(1:n, n/2)] <- 1
# Generate binary covariate variable
x1 <- rbinom(n, 1, p = 0.5)
# Generate continuous covariate variable
x2 <- rnorm(n)
# Create binary mediator
m <- c(1, 1, 0, 1, 1, 1, 1, 0, 1, 1,
       0, 1, 1, 1, 1, 0, 1, 0, 1, 0,
       1, 1, 0, 1, 0, 1, 1, 1, 1, 0,
       1, 1, 0, 1, 0, 1, 1, 0, 1, 1,
       0, 1, 1, 0, 0, 1, 1, 1, 0, 1)
# Create Zero-inflated Count Outcome
y <- c(0, 7, 0, 0, 8, 0, 7, 3, 5, 0,
       5, 0, 0, 1, 10,0, 3, 4, 5, 7,
       9, 7, 0, 6, 2, 4, 0, 0, 0, 6,
       0, 11,0, 5, 6, 0, 0, 12,0, 0,
       13,6, 8, 6, 5, 0, 4, 0, 6, 8)
sdata <- data.frame(z, x1, x2, m, y)
mFit <- glm(m ~ z + x1 + x2, data = sdata, family = binomial)
# Fit with Zero-inflated Poisson model
yzipFit <- zeroinfl(y ~ z + m + x1 + x2, data = sdata)
# Estimation via Quasi-Bayesian approximation
zipMA <- mediate_zi(mFit, yzipFit, sims = 100, treat = "z", mediator = "m")
summary(zipMA)
# Estimation via bootstrap approximation
zipMA_bt <- mediate_zi(mFit, yzipFit, sims = 100, boot = TRUE, treat = "z",
mediator = "m")
summary(zipMA_bt)

Mediation Sensitivity Analysis for Count and Zero-Inflated Count Data with a Post-Treatment Confounder

Description

'mediate_zi_vcoef' is modified from mediate_zi function with 3 confounder-related parameters ('model.u', 'delta.beta.u', and 'confounder') added. It is used to estimate causal mediation effects when there is a treatment-induced mediator-outcome confounder, and the coefficient of treatment in the confounder model is specified by users. Users can perform sensitivity analysis with a range of specified coefficient values when there is a post-treatment confounder.

Usage

mediate_zi_vcoef(
  model.u,
  delta.beta.u,
  model.m,
  model.y,
  sims = 1000,
  boot = FALSE,
  treat = "treat.name",
  mediator = "med.name",
  confounder = "confd.name",
  covariates = NULL,
  outcome = NULL,
  control = NULL,
  conf.level = 0.95,
  control.value = 0,
  treat.value = 1,
  long = TRUE,
  dropobs = FALSE,
  robustSE = FALSE,
  cluster = NULL,
  ...
)

Arguments

model.u

A fitted model object for confounder. Can be of class 'lm', 'polr', 'bayespolr', 'glm', 'bayesglm', 'gam', 'rq', or 'survreg'.

delta.beta.u

Sensitivity parameter as difference from the estimated treatment coefficient in the confounder model (model.u) based on the observed data.

model.m

A fitted model object for mediator. Can be of class 'lm', 'polr', 'bayespolr', 'glm', 'bayesglm', 'gam', 'rq', or 'survreg'.

model.y

A fitted model object for outcome. Can be of class 'lm', 'polr', 'bayespolr', 'glm', 'bayesglm', 'gam', 'vglm', 'rq', 'survreg', or 'zeroinfl'

sims

Number of Monte Carlo draws for nonparametric bootstrap or quasi-Bayesian approximation.

boot

A logical value. if 'FALSE' a quasi-Bayesian approximation is used for confidence intervals; if 'TRUE' nonparametric bootstrap will be used. Default is 'FALSE'.

treat

A character string indicating the name of the treatment variable used in the models. The treatment can be either binary (integer or a two-valued factor) or continuous (numeric).

mediator

A character string indicating the name of the mediator variable used in the models.

confounder

A character string indicating the name of the confounder variable used in the models.

covariates

A list or data frame containing values for a subset of the pre-treatment covariates in 'model.m' and 'model.y'. If provided, the function will return the estimates conditional on those covariate values.

outcome

A character string indicating the name of the outcome variable in ‘model.y’. Only necessary if 'model.y' is of class 'survreg'; otherwise ignored.

control

A character string indicating the name of the control group indicator. Only relevant if 'model.y' is of class 'gam'. If provided, 'd0', 'z0' and 'n0' are allowed to differ from 'd1', 'z1' and 'n1', respectively.

conf.level

Level of the returned two-sided confidence intervals. Default is to return the 2.5 and 97.5 percentiles of the simulated quantities.

control.value

Value of the treatment variable used as the control condition. Default is 0.

treat.value

Value of the treatment variable used as the treatment condition. Default is 1.

long

A logical value. If 'TRUE', the output will contain the entire sets of simulation draws of the the average causal mediation effects, direct effects, proportions mediated, and total effect. Default is 'TRUE'.

dropobs

A logical value indicating the behavior when the model frames of 'model.m' and 'model.y' (and the 'cluster' variable if included) are composed of different observations. If 'TRUE', models will be re-fitted using common data rows. If 'FALSE', error is returned. Default is 'FALSE'.

robustSE

A logical value. If 'TRUE', heteroskedasticity-consistent standard errors will be used in quasi-Bayesian simulations. Ignored if 'boot' is 'TRUE' or neither 'model.m' nor 'model.y' has a method for vcovHC in the sandwich package. Default is 'FALSE'.

cluster

A variable indicating clusters for standard errors. Note that this should be a vector of cluster indicators itself, not a character string for the name of the variable.

...

other arguments passed to vcovHC in the sandwich package: typically the 'type' argument, which is ignored if 'robustSE' is 'FALSE'. Arguments to the boot in the boot package may also be passed, e.g. 'parallel' and 'ncpus'.

Value

mediate_zi_vcoef returns an object of class "mediate", (or "mediate.order" if the outcome model used is 'polr' or 'bayespolr'), a list that contains the components listed below. Some of these elements are not available if 'long' is set to 'FALSE' by the user.

The function summary (i.e., summary.mediate, or summary.mediate.order) can be used to obtain a table of the results. The function plot (i.e., plot.mediate, or plot.mediate.order) can be used to produce a plot of the estimated average causal mediation, average direct, and total effects along with their confidence intervals.

d0, d1

point estimates for average causal mediation effects under the control and treatment conditions.

d0.ci, d1.ci

confidence intervals for average causal mediation effects. The confidence level is set at the value specified in 'conf.level'.

d0.p, d1.p

two-sided p-values for average causal mediation effects.

d0.sims, d1.sims

vectors of length 'sims' containing simulation draws of average causal mediation effects.

z0, z1

point estimates for average direct effect under the control and treatment conditions.

z0.ci, z1.ci

confidence intervals for average direct effects.

z0.p, z1.p

two-sided p-values for average causal direct effects.

z0.sims, z1.sims

vectors of length 'sims' containing simulation draws of average direct effects.

n0, n1

the "proportions mediated", or the size of the average causal mediation effects relative to the total effect.

n0.ci, n1.ci

confidence intervals for the proportions mediated.

n0.p, n1.p

two-sided p-values for proportions mediated.

n0.sims, n1.sims

vectors of length 'sims' containing simulation draws of the proportions mediated.

tau.coef

point estimate for total effect.

tau.ci

confidence interval for total effect.

tau.p

two-sided p-values for total effect.

tau.sims

a vector of length 'sims' containing simulation draws of the total effect.

d.avg, z.avg, n.avg

simple averages of d0 and d1, z0 and z1, n0 and n1, respectively, which users may want to use as summary values when those quantities differ.

d.avg.ci, z.avg.ci, n.avg.ci

confidence intervals for the above.

d.avg.p, z.avg.p, n.avg.p

two-sided p-values for the above.

d.avg.sims, z.avg.sims, n.avg.sims

vectors of length 'sims' containing simulation draws of d.avg, z.avg and n.avg, respectively.

boot

logical, the 'boot' argument used. If 'FALSE' a quasi-Bayesian approximation was used for confidence intervals; if 'TRUE' nonparametric bootstrap was used

boot.ci.type

a character string 'perc' indicating percentile bootstrap confidence intervals were estimated if the argument boot = TRUE

treat

a character string indicating the name of the 'treat' variable used in the models.

mediator

a character string indicating the name of the 'mediator' variable used in the models.

INT

a logical value indicating whether the model specification allows the effects to differ between the treatment and control conditions.

conf.level

the confidence level used.

model.y

the outcome model used.

model.m

the mediator model used.

control.value

value of the treatment variable used as the control condition.

treat.value

value of the treatment variable used as the treatment condition.

nobs

number of observations in the model frame for 'model.m' and 'model.y'. May differ from the numbers in the original models input to 'mediate' if 'dropobs' was 'TRUE'.

robustSE

‘TRUE’ or ‘FALSE’.

cluster

the clusters used.

Author(s)

Nancy Cheng, [email protected]; Jing Cheng, [email protected].

References

Cheng, J., Cheng, N.F., Guo, Z., Gregorich, S., Ismail, A.I., Gansky, S.A (2018) Mediation analysis for count and zero-inflated count data. Statistical Methods in Medical Research. 27(9):2756-2774.

Ismail AI, Ondersma S, Willem Jedele JM, et al. (2011) Evaluation of a brief tailored motivational intervention to prevent early childhood caries. Community Dentistry and Oral Epidemiology 39: 433–448.

Tingley, D., Yamamoto, T., Hirose, K., Imai, K. and Keele, L. (2014). "mediation: R package for Causal Mediation Analysis", Journal of Statistical Software, Vol. 59, No. 5, pp. 1-38.

Imai, K., Keele, L., Tingley, D. and Yamamoto, T. (2011). Unpacking the Black Box of Causality: Learning about Causal Mechanisms from Experimental and Observational Studies, American Political Science Review, Vol. 105, No. 4 (November), pp. 765-789.

Imai, K., Keele, L. and Tingley, D. (2010) A General Approach to Causal Mediation Analysis, Psychological Methods, Vol. 15, No. 4 (December), pp. 309-334.

Imai, K., Keele, L. and Yamamoto, T. (2010) Identification, Inference, and Sensitivity Analysis for Causal Mediation Effects, Statistical Science, Vol. 25, No. 1 (February), pp. 51-71.

Imai, K., Keele, L., Tingley, D. and Yamamoto, T. (2009) "Causal Mediation Analysis Using R" in Advances in Social Science Research Using R, ed. H. D. Vinod New York: Springer.

See Also

plot_sensitivity, mediate_zi, summary.mediate, plot.mediate

Examples

data("midvd_bt100")
uFit <- glm (PDVisit_6 ~ intervention + BrushTimes_W2 + HealthyMeals_W2
                         + PDVisit_W2,
             family = 'binomial', data = midvd_bt100)
mFit <- glm (PBrushBedt_6 ~ intervention + BrushTimes_W2 + HealthyMeals_W2
                            + PBrush_W2 + PDVisit_6,
             family = 'binomial', data = midvd_bt100)
yFit <- zeroinfl(Untreated_W3 ~ intervention + PBrushBedt_6 + BrushTimes_W2
                                + HealthyMeals_W2 + PBrush_W2+ PDVisit_6,
                 data = midvd_bt100)
# For illustration purposes a small number of simulations are used
# Estimation via Quasi-Bayesian approximation
ee <-mediate_zi_vcoef(uFit, delta.beta.u = 0.01, mFit, yFit, sims = 100,
                      treat = "intervention", mediator = "PBrushBedt_6",
                      confounder ="PDVisit_6")
summary(ee)

Example Data for mediate_zi_vcoef, plot_sensitivity and mediate_iv Functions

Description

A bootstrap random subsample of the DDHP MI-DVD trial data used in Cheng, J., Cheng, N.F., Guo, Z., Gregorich, S., Ismail, A.I., Gansky, S.A. (2018). In the trial, the enrolled families were examined at Wave 1 (randomization), wave 2 (dental examination and study started, considered as baseline), 6-month follow up, and end of the study (wave 3, 2-year). This bootstrap subsample data contain 100 rows and 9 columns with no missing values. The data are provided only for illustrative purposes.

Usage

midvd_bt100

Format

A data frame containing the following variables:

BrushTimes_W2:

Number of times child brushed per day in a typical week measured at wave 2 (baseline).

HealthyMeals_W2:

A binary variable indicating whether caregivers gave child healthy meals measured at wave 2 (baseline) (1=Yes, 0=No).

PBrush_W2:

A binary variable indicating whether caregivers made sure child brushed 2 times per day measured at wave 2 (baseline) (1=Yes, 0=No).

PDVisit_W2:

A binary variable indicating whether caregiver makes sure child sees dentists every 6 mos measured at wave 2 (baseline) (1=Yes, 0=No).

PDVisit_6:

A binary variable indicating whether caregiver makes sure child sees dentists every 6 mos measured at 6-month follow up (1=Yes, 0=No).

PBrushBedt_6:

A binary variable indicating whether caregivers made sure child brushes teeth at bedtime measured at 6-month follow up (1=Yes, 0=No).

PBrush_6:

A binary variable indicating whether caregivers made sure child brushed 2 times per day measured at 6-month follow up (1=Yes, 0=No).

intervention:

A binary treatment variable (1=intervention 0=Control).

Untreated_W3:

The number of new untreated lesions measured at end of the 2-year study.

Source

Ismail AI, Ondersma S, Willem Jedele JM, et al. (2011) Evaluation of a brief tailored motivational intervention to prevent early childhood caries. Community Dentistry and Oral Epidemiology 39: 433–448.

Cheng, J., Cheng, N.F., Guo, Z., Gregorich, S., Ismail, A.I., Gansky, S.A. (2018) Mediation analysis for count and zero-inflated count data. Statistical Methods in Medical Research. 27(9):2756-2774.


Plot Sensitivity Graph

Description

'plot_sensitivity' performs sensitivity analysis when there is a treatment- induced mediator-outcome confounder by varying coefficient of treatment in the confounder model and plots sensitivity graph.

Usage

plot_sensitivity(
  model.u,
  n.beta.u = 10,
  model.m,
  model.y,
  sims = 1000,
  boot = FALSE,
  confounder = "confd.name",
  treat = "treat.name",
  mediator = "med.name",
  covariates = NULL,
  outcome = NULL,
  digits = 3,
  xlab = "Beta.u",
  ylab = "Effect",
  xlim = NULL,
  ylim = NULL,
  main = NULL,
  type = "l",
  col = c("black", "black", "black"),
  pch = NULL,
  lty = c(1, 2, 3),
  legend.x,
  legend.y = NULL,
  legend.inset = 0.05,
  legend = c("Direct Effect", "Mediation Effect", "Total Effect"),
  legend.horiz = FALSE
)

Arguments

model.u

A fitted model object for confounder. Can be of class 'lm', 'polr', 'bayespolr', 'glm', 'bayesglm', 'gam', 'rq', or 'survreg'.

n.beta.u

Number of varying coefficient of treatment in the confounder model. This number is adjusted as n.beta.u + 1 if n.beta.u is an even number.

model.m

A fitted model object for mediator. Can be of class 'lm', 'polr', 'bayespolr', 'glm', 'bayesglm', 'gam', 'rq', or 'survreg'.

model.y

A fitted model object for outcome. Can be of class 'lm', 'polr', 'bayespolr', 'glm', 'bayesglm', 'gam', 'vglm', 'rq', 'survreg', or 'zeroinfl'.

sims

Number of Monte Carlo draws for quasi-Bayesian approximation.

boot

A logical value. if 'FALSE' a quasi-Bayesian approximation is used for confidence intervals; if 'TRUE' nonparametric bootstrap will be used. Default is 'FALSE'.

confounder

A character string indicating the name of the confounder variable used in the models.

treat

A character string indicating the name of the treatment variable used in the models. The treatment can be either binary (integer or a two-valued factor) or continuous (numeric).

mediator

A character string indicating the name of the mediator variable used in the models.

covariates

A list or data frame containing values for a subset of the pre-treatment covariates in 'model.m' and 'model.y'. If provided, the function will return the estimates conditional on those covariate values. Default is NULL.

outcome

A character string indicating the name of the outcome variable in ‘model.y’. Only necessary if 'model.y' is of class 'survreg'; otherwise ignored.Default is NULL.

digits

integer indicating the number of decimal places to round the values to be returned. Default is 3.

xlab, ylab

Labels for x and y axes, as in plot. Default xlab = "Beta.u", ylab = "Effect".

xlim, ylim

Ranges of x and y axes, as in plot. The default value, NULL, indicates that the range of the finite values to be plotted should be used.

main

A main title for the plot, as in plot.

type

A character string (length 1 vector) or vector of 1-character strings indicating the type of plot for 3 columns of y, as in plot. Default is 'l' for lines.

col

A vector of strings indicating the colors for 3 lines of y. Default is ("black","black","black").

pch

A vector of plotting characters or symbols, as in plot. Default is NULL.

lty

A vector of line types, as in plot. Default is c(1,2,3).

legend.x, legend.y

The x and y co-ordinates to be used to position the legend, see x, y in legend. Default legend.y = NULL.

legend.inset

Inset distance(s) from the margins as a fraction of the plot region when legend is placed by keyword, as inset in legend. Default is 0.05.

legend

A character or expression vector of 3 to appear in the legend, as in legend. Default is c("Direct Effect", "Mediation Effect", "Total Effect")

legend.horiz

A logical value. If TRUE, set the legend horizontally Default is FALSE, which sets the legend vertically.

Details

The function uses the estimated coefficient of treatment in the fitted confounder model with observed data (see Cheng et al 2018) as the middle point (mid.beta.u), and calculates 1 unit change in the coefficient as |2*mid.beta.u/3/(n-1)| where n = n.beta.u if n.beta.u is an odd number and n = n.beta.u+1 if n.beta.u is an even number, and n.beta.u is the number of varying coefficient of treatment specified by users. mediate_zi_vcoef is then used to estimate average causal mediation effects (indirect effect), average direct effects, and total effect for each value of the treatment coefficient in the confounder model. The function prints all the effect estimates, and produces the sensitivity graph.

Value

plot_sensitivity produces sensitivity graph and returns an object of data frame with the following columns:

beta.u

coefficient of treatment in the confounder model.

d0, d1

point estimates for average causal mediation effects under the control and treatment conditions.

z0, z1

point estimates for average direct effect under the control and treatment conditions.

d.avg, z.avg

simple averages of d0 and d1, z0 and z1, respectively.

tau.coef

point estimate for total effect.

Author(s)

Nancy Cheng, [email protected]; Jing Cheng, [email protected].

References

Cheng, J., Cheng, N.F., Guo, Z., Gregorich, S., Ismail, A.I., Gansky, S.A (2018) Mediation analysis for count and zero-inflated count data. Statistical Methods in Medical Research. 27(9):2756-2774.

Ismail AI, Ondersma S, Willem Jedele JM, et al. (2011) Evaluation of a brief tailored motivational intervention to prevent early childhood Community Dentistry and Oral Epidemiology 39: 433–448.

See Also

mediate_zi_vcoef

Examples

data("midvd_bt100")
uFit <- glm(PDVisit_6 ~ intervention + BrushTimes_W2 + HealthyMeals_W2
                        + PDVisit_W2,
            family = 'binomial', data = midvd_bt100)
mFit <- glm(PBrushBedt_6 ~ intervention + BrushTimes_W2 + HealthyMeals_W2
                           + PBrush_W2 + PDVisit_6,
            family = 'binomial', data = midvd_bt100)
yFit <- zeroinfl(Untreated_W3 ~ intervention + PBrushBedt_6 + BrushTimes_W2
                                + HealthyMeals_W2 + PBrush_W2 + PDVisit_6,
                 data = midvd_bt100)
# For illustration purposes a small number of simulations are used
plot_sensitivity(uFit, n.beta.u = 5, mFit, yFit, sims = 25,
                 treat = "intervention", mediator = "PBrushBedt_6",
                 confounder = "PDVisit_6",
                 main = "Effects on the number of new untreated cavities at 2 years",
                 legend.x = "right")