med_multi: 'med_multi'

Description Usage Arguments Examples

View source: R/med_multi.R

Description

Decomposes the effect of an exposure on an outcome into a direct effect operating through a set of intermediary variables, and a direct effect involving other pathways. A key assumption is the dual lack of confounding of the exposure-outcome, and the mediator-outcome associations. Described in chapter 5.2.1 of Tyler's book.

Usage

1
2
med_multi(dat, A, Y, M, C = NULL, fam = gaussian(link = "identity"),
  boot = 10, nmin = 10, mids = NULL, maxit = 5)

Arguments

dat

a dataframe containing the exposure, outcome, mediators, and confounders

A

the exposure of interest. Currently must be categorical (or binary)

Y

the outcome, currently must be continuous, ordinal or binary

M

the mediators of interest

C

confounders of either X -> M and/or M -> Y.

fam

specifies GLM link function and distribution of residuals. Default is gaussian(link = identity)

boot

number of bootstrap samples used to build the 95p confidence intervals

nmin

number of participants all categories of exposure must have; samples will be redrawn if this criterion is not met

mids

an optional mids object to serve as template for imputations

Examples

1
2
3
4
5
6
my_list <- med_multi(dat = df,
 X = my_exposure,
 M = mediator_1 + mediator_2 + ... + mediator_1*mediator_2 + mediator_1*exposure,
 Y = my_continuous_outcome,
 C = a_confounder + another_confounder * anything,
 fam = gaussian(link = "identity"), boot = 1000)

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