med_reg: 'med_reg' Gives controlled direct effect, natural indirect...

Description Usage Arguments Value Examples

View source: R/med_reg.R

Description

med_reg Gives controlled direct effect, natural indirect effect, natural direct effect using regression-based formulas affording the best statistical power. The procedure is described in chapter 3.1.1 of Tyler's book

Usage

1
2
med_reg(df, X, M, Y, C = "", noint = FALSE, mlvl = NULL, delta = FALSE,
  ref = 0, treat = 1)

Arguments

df

Data frame

X

exposure, can be continuous or categorical

M

mediator, must be continuous for the moment

Y

outcome, must be continuous for the moment

C

confounders of exposure-outcome or mediator-outcome association. Can take any form

noint

supress exposure-mediator interaction term

mlvl

vector of values at which to compute a controlled direct effect

delta

whether the delta method should be used to get confidence intervals

ref

referent level of exposure, 0 by default

treat

treatment level of exposure, 1 by default

Value

a list composed of the natural direct effect, natural indirect effect, total effect, and a controlled direct effect for each line given in mlvl

Examples

1
2
3
4
5
6
7
8
my_list <-med_reg(my_df,
 X = "my_exposure",
 M = "my_continuous_mediator",
 Y = "my_continuous_outcome",
 C = c("confounder_1", "confounder_2"),
 treat = high_exposure_level,
 ref = low_exposure_level,
 mlvl = seq(25, 40, by=5) ## possible BMI values for the mediator

kaskarn/causamed documentation built on Dec. 28, 2021, 11:01 a.m.