rbwMed {rbw}R Documentation

Residual Balancing Weights for Causal Mediation Analysis

Description

rbwMed is a function that produces residual balancing weights for estimating controlled direct/mediator effects in causal mediation analysis. The user supplies a (optional) set of baseline confounders and a list of model objects for the conditional mean of each post-treatment confounder given the treatment and baseline confounders. The weights can be used to fit marginal structural models for the joint effects of the treatment and a mediator on an outcome of interest.

Usage

rbwMed(
  treatment,
  mediator,
  zmodels,
  data,
  baseline_x,
  interact = FALSE,
  base_weights,
  max_iter = 200,
  tol = 1e-04,
  print_level = 1
)

Arguments

treatment

A symbol or character string for the treatment variable in data.

mediator

A symbol or character string for the mediator variable in data.

zmodels

A list of fitted lm or glm objects for post-treatment confounders of the mediator-outcome relationship. If there's no post-treatment confounder, set it to be NULL.

data

A data frame containing all variables in the model.

baseline_x

(Optional) An expression for a set of baseline confounders stored in data or a character vector of the names of these variables.

interact

A logical variable indicating whether baseline and post-treatment covariates should be balanced against the treatment-mediator interaction term(s).

base_weights

(Optional) A vector of base weights (or its name).

max_iter

Maximum number of iterations for Newton's method in entropy minimization.

tol

Tolerance parameter used to determine convergence in entropy minimization. See documentation for eb2.

print_level

The level of printing. See documentation for eb2.

Value

A list containing the results.

weights

A vector of residual balancing weights.

constraints

A matrix of (linearly independent) residual balancing constraints

eb_out

Results from calling the eb2 function

call

The matched call.

Examples

# models for post-treatment confounders
m1 <- lm(threatc ~ ally + trade + h1 + i1 + p1 + e1 + r1 +
  male + white + age + ed4 + democ, data = peace)

m2 <- lm(cost ~ ally + trade + h1 + i1 + p1 + e1 + r1 +
  male + white + age + ed4 + democ, data = peace)

m3 <- lm(successc ~ ally + trade + h1 + i1 + p1 + e1 + r1 +
  male + white + age + ed4 + democ, data = peace)

# residual balancing weights
rbwMed_fit <- rbwMed(treatment = democ, mediator = immoral,
  zmodels = list(m1, m2, m3), interact = TRUE,
  baseline_x = c(ally, trade, h1, i1, p1, e1, r1, male, white, age, ed4),
  data = peace)

# attach residual balancing weights to data
peace$rbw_cde <- rbwMed_fit$weights

# fit marginal structural model
if(require(survey)){
  rbw_design <- svydesign(ids = ~ 1, weights = ~ rbw_cde, data = peace)
  msm_rbwMed <- svyglm(strike ~ democ * immoral, design = rbw_design)
  summary(msm_rbwMed)
}

[Package rbw version 0.3.2 Index]