med_iptw: Marginal structural models to compute controlled direct...

Description Usage Arguments Value Examples

View source: R/med_iptw.R

Description

med_iptw Computes CDE(M) for given mediator levels, in a setting with an exposure-induced confounder of the mediator-outcome association. Described in chapter 5.3.1 of Tyler's book

Usage

1
2
3
med_iptw(dat, A, M, Y, C = NULL, L = NULL, regtype = "gaussian",
  boot = 10, nmin = 10, quants = c(0.025, 0.5, 0.975), mlvl = NULL,
  link = logit, mids = NULL, maxit = 5)

Arguments

dat

The original dataset

A

the exposure of interest. Must be binary or categorical

M

the mediators of interest. Must be binary or categorical

Y

the outcome, currently must be continuous

C

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

L

the exposure-induced confounders of the association of M with Y. Can take any form

boot

specifies the number of bootstrap samples drawn to make the confidence intervals

nmin

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

quants

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

mlvl

a matrix or table of probability-mass functions for the mediator, to calculate CDE(M). By default, mlvl is set to the observed sample distributions

mids

an optional mids object to serve as template for imputations

Value

An S3 object of class cmed.ipw containing:

w the ipw used in the marginal strucutral model

cde.int an array where cde.int[i,,] indexes a matrix corresponding to the CDE calculated for a PMF of M given in mlvl, with each row a bootsrap replicate

cde.noint a matrix of cde given no M*A interaction, with each row a bootstrap replicate

te a matrix of total effects, with each row a bootstrap replicate

ymod1 the marginal strucutral model of Y given no interaction

ymod2 the marginal strucutral model of Y allowing a A*M interaction

Examples

1
my_list <- med_iptw(dat = df,  A = my_exposure, Y = my_outcome, M = my_mediator, C = a_confounder + another_confounder, boot = 1000)

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