med_smean: Structural means model to compute controlled direct effects...

Description Usage Arguments Details Value Examples

View source: R/med_smean.R

Description

med_smean

Usage

1
2
med_smean(dat, A, Y, M, C = NULL, L = NULL, boot = 10, nmin = 10,
  mlvl = NULL, quants = c(0.025, 0.5, 0.975), mids = NULL, maxit = 5)

Arguments

dat

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

A

the exposure of interest. Can take any form

Y

the outcome, currently must be continuous

M

the mediators of interest

C

confounders of either X -> M and/or M -> Y. Can take any form

L

the exposure-induced confounders of the association of M with Y

boot

the number of bootstrap samples used to build confidence intervals

nmin

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

mlvl

the levels of M to calculate corresponding CDE's to. Default is sample average.

quants

an optional vector of quantiles for the confidence interval (95 percent by default)

mids

an optional mids object to serve as template for imputations

Details

Returns the controlled direct effect CDE(M) of an exposure A on an outcome Y, not operating through a mediator M, in the case of exposure-induced confounding of the M->Y association. Follows section 5.3.5 of Vanderweele's book on causal mediation analysis.

Value

An S3 object of class cmed_smean containing:

k2 the coefficient of M in regression of A, M, L and C on Y

k3 the coefficient of A*M from regression of A, M, L and C on Y

g1 the coefficient g1 from the regression of A and C on partial residuals of Y

ymod1 the model of Y for the last bootstrap sample

ymod2 the model of Y residuals for the last bootstrap sample

cde array story controlled direct effects from bootstrapped results

Examples

1
my_list <- med_smean(data, A, Y, M, c1 + c2 + c3 + c2*c3, mlvl = quantiles(M, probs = c(0.25, 0.5, 0.75)))

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