eb_mediation: Estimate Energy Balancing Weights for Mediation Analysis

View source: R/eb_wrappers.R

eb_mediationR Documentation

Estimate Energy Balancing Weights for Mediation Analysis

Description

eb_mediation is a wrapper for energybalance that focuses on using it to estimate energy balancing weights for the mean cross-world potential outcome in mediation analysis. Estimation proceeds in two steps. First, the control group covariate distribution is weighted to resemble the full sample. Second, the treated group covariate and mediator distribution is weighted to resemble the weighted control group. Weights are produced for the treated group.

Usage

eb_mediation(sampleX, Z, M, sampleW = NULL,
             std = "studentized", lambda = 0)

Arguments

sampleX

a matrix or data frame of covariates composing the sample distribution to be weighted. See energybalance for how this is processed.

Z

a vector denoting treatment group membership. The group with Z==1 will be the treated group for which the weights are being estimated, and the group with Z==0 will be the control group that the weighted treatment group is meant to resemble.

M

a vector or matrix containing the values of the mediator(s). This is processed the same way as sampleX.

sampleW

optional; a vector of sampling weights for the sample. The product of the estimated weights and sampleW will be the distribution-matching weights.

std

character; whether to standardize the covariates. If "studentized", the distance matrix used will be the Euclidean distance with each variable scaled using its standard deviation in the target distribution (weighted by targetW if supplied). If "mahalanobis", the distance matrix used will be the Mahalanobis distance computed using the covariance matrix of the target distribution (weighted by targetW if supplied). If "none", the distance matrix used will be the Euclidean distance matrix. Default is "studentized". Abbreviations allowed.

lambda

a penalty on the sum of the squared weights. lambda/nrow(sampleX)^2 times the sum of the squared weights is added to the objective function. Increasing lambda preserves the effective sample size of the weighted sample at the expense of balance.

Value

A vector of weights for the treated group.

Author(s)

Noah Greifer

See Also

energybalance


ngreifer/energybalance documentation built on July 27, 2022, 5:50 a.m.