TTS: Natural Mediated Effects

Description Usage Arguments Value Examples

View source: R/TTS.R

Description

TTS is used to estimate natural direct and natural indirect effects using the methods of Tchetgen Tchetgen Shpitser (2012). This implementation can be used with a binary exposure, binary or continuous mediator, and continuous outcome. Linear models are used to model the conditional expectation of continuous quantities, and logisitc regression models are used to model binary quantities. As with the plmed function, the confounder set is the union terms in the exposure.formula, mediator.formula, and outcome.formula. Missing data behaviour is always na.action=na.omit.

Usage

1
2
3
4
5
6
7
8
TTS(
  exposure.formula,
  mediator.formula,
  outcome.formula,
  mediator.family = "gaussian",
  data,
  weights
)

Arguments

exposure.formula

an object of class formula (or one that can be coerced to that class) where the left hand side of the formula contains the binary exposure variable of interest.

mediator.formula

an object of class formula (or one that can be coerced to that class) where the left hand side of the formula contains the mediator variable of interest.

outcome.formula

an object of class formula (or one that can be coerced to that class) where the left hand side of the formula contains the outcome variable of interest.

mediator.family

link function for the mediator model, can be either "gaussian" or "binomial"

data

an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which TTS is called.

Value

An object of class plmed with Total Effect (TE), Natural Direct Effect (NDE) and Natural Indirect Effect (NIDE) estimates, with estimated standard errors, and Wald based test statistics.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Example on Generated data
N <- 100
beta <- c(1,0,1) #Some true parameter values
#Generate data on Confounders (Z), Exposure (X)
#Mediator (M), Outcome (Y)
Z <- rnorm(N)
X <- rbinom(N,1,1/(exp(-Z)+1))
M <- beta[1]*X + Z +rnorm(N)
Y <- beta[2]*M + beta[3]*X + Z +rnorm(N)

TTS(X~Z,M~Z,Y~Z,"gaussian")

#Example on Generated data
N <- 100
beta <- c(1,0,1) #Some true parameter values
#Generate data on Confounders (Z), Exposure (X)
#Mediator (M), Outcome (Y)
Z <- rnorm(N)
X <- rbinom(N,1,plogis(Z))
M <- rbinom(N,1,plogis(X+Z))
Y <- beta[2]*M + beta[3]*X + Z +rnorm(N)

TTS(X~Z,M~Z,Y~Z,"binomial")

ohines/plmed documentation built on Jan. 9, 2021, 11:59 a.m.