ebalance_custom: Modified version of ebalance (originally from Jens...

View source: R/ebalance.R

ebalance_customR Documentation

Modified version of ebalance (originally from Jens Hainmueller)

Description

This is a custom version of the ebal (entropy balancing) package by Jens Hainmueller. Chooses weights on controls to make covariate means equal to those of treated. This version differs from ebal only in that it handles cases where there is only a single unit, which otherwise causes a problem in the original code.

Usage

ebalance_custom(
  Treatment,
  X,
  base.weight = NULL,
  norm.constant = NULL,
  coefs = NULL,
  max.iterations = 200,
  constraint.tolerance = 0.001,
  print.level = 0
)

Arguments

Treatment

a numeric vector of length equal to the total number of units where treated (population) units take a value of 1 and control (sampled) units take a value of 0.

X

matrix of data where rows are observations and columns are covariates.

base.weight

an optional numeric vector argument of length equal to the total number of control units to specify the base weight of each control unit within entropy balancing. Default is even weights (1) for all controls.

norm.constant

an optional numeric argument; users should leave unspecified in most cases.

coefs

an optional vector argument of length equal to one more than the number of covariates in X; users should leave unspecified in most cases.

max.iterations

numeric maximum number of iterations to use when searching for weights

constraint.tolerance

numeric tolerance level.

print.level

a numeric argument to specify the amount of information printed out. 0 is silent, 1 prints convergence status, 2 prints maximum deviance per iteration, 3 prints loss and step length.

Value

target.margins

Column sums of X among the treated units.

co.xdata

Covariate matrix for the controls only built from X with an additional appended column of ones.

w

weights found using ebalance. Note that treated units all receive flat weights of 1

maxdiff

absolute value of the largest component of the gradient in the last iteration.

norm.constant

norm constant used

constraint.tolerance

tolerance used to evaluate convergence

max.iterations

max iterations used

base.weight

base weights used

print.level

print level used

converged

Convergence status. If ebalance failed to find weights within the specified constraint.tolerance after max.iterations this is FALSE. Note that even if ebalance does not converge, the last iteration's weights w are returned.


kbal documentation built on April 3, 2025, 6:04 p.m.

Related to ebalance_custom in kbal...