The `mediator` R function conducts mediation analysis under the counterfactual framework assuming interation between the exposure and mediator. Currently the function works for binary and continuous outcomes and mediators.

mediator(...)

# S3 method for default
mediator(
  data,
  out.model,
  med.model,
  treat,
  a = 1,
  a_star = 0,
  m = 0,
  boot_rep = 0,
  pm_ci = FALSE,
  ...
)

Arguments

...

other arguments

data

Data set to use for analysis

out.model

A fitted model object for the outcome. Can be of class 'glm','lm', or 'coxph'.

med.model

A fitted model object for the mediator. Can be of class 'glm','lm'.

treat

A character string indicating the name of the treatment/exposure variable used.

a

A numeric value indicating the exposure level. Default = 1

a_star

A numeric value indicating the compared exposure level. Default = 0.

m

A numeric value indicating the level of the mediator. Default = 0.

boot_rep

A numeric value indicating the number of repetitions to use when utalizing bootstrap to calculate confidence intervals. When `boot_rep` = 0, the Delta method for calculating confidence intervals is used. Default = 0.

pm_ci

A logical indicator for calculating the CI for the proportion mediated. Default = FALSE. Currently, the CI can only be determined using boostrapping. If `pm_ci` = TRUE and `boot_rep` = 0 then 100 replicated are automatically used.

Value

Tibble containing point estimates and 95 percent CI for the CDE, NDE, NIE and TE and the point estimate for the proportion mediated.