regmedint {regmedint}R Documentation

regmedint: A package for regression-based causal mediation analysis

Description

The package is an R implementation of regression-based closed-form causal mediation as originally described in Valeri & VanderWeele 2013 and Valeri & VanderWeele 2015 https://www.hsph.harvard.edu/tyler-vanderweele/tools-and-tutorials/. The earlier version is a sister program of the SAS macro. The current extended version (version 1.0 and later) supports effect modification by covariates (treatment-covariate and mediator-covariate product terms) in mediator and outcome models.

This is a user-interface for regression-based causal mediation analysis as described in Valeri & VanderWeele 2013 and Valeri & VanderWeele 2015.

Usage

regmedint(
  data,
  yvar,
  avar,
  mvar,
  cvar,
  emm_ac_mreg = NULL,
  emm_ac_yreg = NULL,
  emm_mc_yreg = NULL,
  eventvar = NULL,
  a0,
  a1,
  m_cde,
  c_cond,
  mreg,
  yreg,
  interaction = TRUE,
  casecontrol = FALSE,
  na_omit = FALSE
)

Arguments

data

Data frame containing the following relevant variables.

yvar

A character vector of length 1. Outcome variable name. It should be the time variable for the survival outcome.

avar

A character vector of length 1. Treatment variable name.

mvar

A character vector of length 1. Mediator variable name.

cvar

A character vector of length > 0. Covariate names. Use NULL if there is no covariate. However, this is a highly suspicious situation. Even if avar is randomized, mvar is not. Thus, there are usually some confounder(s) to account for the common cause structure (confounding) between mvar and yvar.

emm_ac_mreg

A character vector of length > 0. Effect modifiers names. The covariate vector in treatment-covariate product term in the mediator model.

emm_ac_yreg

A character vector of length > 0. Effect modifiers names. The covariate vector in treatment-covariate product term in the outcome model.

emm_mc_yreg

A character vector of length > 0. Effect modifiers names. The covariate vector in mediator-covariate product term in outcome model.

eventvar

An character vector of length 1. Only required for survival outcome regression models. Note that the coding is 1 for event and 0 for censoring, following the R survival package convention.

a0

A numeric vector of length 1. The reference level of treatment variable that is considered "untreated" or "unexposed".

a1

A numeric vector of length 1.

m_cde

A numeric vector of length 1. Mediator level at which controlled direct effect is evaluated at.

c_cond

A numeric vector of the same length as cvar. Covariate levels at which natural direct and indirect effects are evaluated at.

mreg

A character vector of length 1. Mediator regression type: "linear" or "logistic".

yreg

A character vector of length 1. Outcome regression type: "linear", "logistic", "loglinear", "poisson", "negbin", "survCox", "survAFT_exp", or "survAFT_weibull".

interaction

A logical vector of length 1. The presence of treatment-mediator interaction in the outcome model. Default to TRUE.

casecontrol

A logical vector of length 1. Default to FALSE. Whether data comes from a case-control study.

na_omit

A logical vector of length 1. Default to FALSE. Whether to remove NAs in the columns of interest before fitting the models.

Value

regmedint object, which is a list containing the mediator regression object, the outcome regression object, and the regression-based mediation results.

Fitting models

Use the regmedint function to fit models and set up regression-based causal mediation analysis.

Examining results

Several methods are available to examine the regmedint object. print summary coef confint

Examples

library(regmedint)
data(vv2015)
regmedint_obj1 <- regmedint(data = vv2015,
                            ## Variables
                            yvar = "y",
                            avar = "x",
                            mvar = "m",
                            cvar = c("c"),
                            eventvar = "event",
                            ## Values at which effects are evaluated
                            a0 = 0,
                            a1 = 1,
                            m_cde = 1,
                            c_cond = 3,
                            ## Model types
                            mreg = "logistic",
                            yreg = "survAFT_weibull",
                            ## Additional specification
                            interaction = TRUE,
                            casecontrol = FALSE)
summary(regmedint_obj1)

regmedint_obj2 <- regmedint(data = vv2015,
                            ## Variables
                            yvar = "y",
                            avar = "x",
                            mvar = "m",
                            cvar = c("c"),
                            emm_ac_mreg = c("c"), 
                            emm_ac_yreg = c("c"), 
                            emm_mc_yreg = c("c"), 
                            eventvar = "event",
                            ## Values at which effects are evaluated
                            a0 = 0,
                            a1 = 1,
                            m_cde = 1,
                            c_cond = 3,
                            ## Model types
                            mreg = "logistic",
                            yreg = "survAFT_weibull",
                            ## Additional specification
                            interaction = TRUE,
                            casecontrol = FALSE)
summary(regmedint_obj2)





[Package regmedint version 1.0.1 Index]