G_estimation: Partially Linear Mediation using G-estimation

Description Usage Arguments Examples

View source: R/G_estimation.R

Description

plmed is used to fit mediation effects for a continuous outcome given a single continuous mediator, binary exposure, and set of variables which adjust for confounding. It is assumed that the outcome and mediator models are linear and the exposure model is logisitic. It uses a G-estimation procedure to estimate direct and indirect effects, with a Bias-Reduced strategy used to estimate nuisance parameters. 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
G_estimation(
  exposure.formula,
  mediator.formula,
  outcome.formula,
  exposure.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 continuous 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 continuous outcome variable of interest.

exposure.family

link function for the exposure model, can be can be a character string naming a family function, a family function or the result of a call to a family function. (See family for details of family functions.)

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 plmed is called.

weights

an optional vector of ‘prior weights’ to be used in the fitting process. Should be NULL or a numeric vector.

#' @return An object of class plmed with, Natural Direct Effect (NDE) and Natural Indirect Effect (NIDE) estimates, as well as the effect of exposure on mediator (X_on_M) and the effect of mediator on outcome (M_on_Y). Estimated standard errors, and Wald based test statistics are also returned, as is the Continuously Updated Estimator score 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
#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 <- beta[1]*X + Z +rnorm(N)
Y <- beta[2]*M + beta[3]*X + Z +rnorm(N)

G_estimation(X~Z,M~Z,Y~Z)


#Example on JobsII data from the mediation package
jobs <- mediation::jobs

Z.formula = c('econ_hard','sex','age','occp',
              'marital','nonwhite','educ','income')
plmed(reformulate(Z.formula,response='treat'),
      reformulate(Z.formula,response='job_seek'),
      reformulate(Z.formula,response='depress2'),
      data=jobs)

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