calc_weight {causalOT}R Documentation

Estimate causal weights

Description

Estimate causal weights

Usage

calc_weight(
  x,
  z,
  estimand = c("ATC", "ATT", "ATE"),
  method = supported_methods(),
  options = NULL,
  weights = NULL,
  ...
)

Arguments

x

A numeric matrix of covariates. You can also pass an object of class dataHolder or DataSim, which will make argument z not necessary,

z

A binary treatment indicator.

estimand

The estimand of interest. One of "ATT","ATC", or "ATE".

method

The method to estimate the causal weights. Must be one of the methods returned by supported_methods().

options

The options for the solver. Specific options depend on the solver you will be using and you can use the solver specific options functions as detailed below..

weights

The sample weights. Should be NULL or have a weight for each observation in the data. Normalized to sum to one.

...

Not used at this time.

Details

We detail some of the particulars of the function arguments below.

Causal Optimal Transport (COT)

This is the.main method of the package. This method relies on various solvers depending on the particular options chosen. Please see cotOptions() for more details.

Energy Balancing Weights (EnergyBW)

This is equivalent to COT with an infinite penalty parameter, options(lambda = Inf). Uses the same solver and options as COT, cotOptions().

Nearest Neighbor Matching with replacement (NNM)

This is equivalent to COT with a penalty parameter = 0, options(lambda = 0). Uses the same solver and options as COT, cotOptions().

Synthetic Control Method (SCM)

The SCM method is equivalent to an OT problem from a different angle. See scmOptions().

Entropy Balancing Weights (EntropyBW)

This method balances chosen functions of the covariates specified in the data argument, x. See entBWOptions() for more details. Hainmueller (2012).

Stable Balancing Weights (SBW)

Entropy Balancing Weights with a different penalty parameter, proposed by Zuizarreta (2012). See sbwOptions() for more details

Covariate Balancing Propensity Score (CBPS)

The CBPS method of Imai and Ratkovic. Options argument is passed to the function CBPS().

Logistic Regression or Probit Regression

The main methods historically for implementing inverse probability weights. Options are passed directly to the glm function from R.

Value

An object of class causalWeights

See Also

estimate_effect()

Examples

set.seed(23483)
n <- 2^5
p <- 6
#### get data ####
data <- Hainmueller$new(n = n, p = p)
data$gen_data()
x <- data$get_x()
z <- data$get_z()

if (torch::torch_is_installed()) {
# estimate weights
weights <- calc_weight(x = x,
                                 z = z, 
                                 estimand = "ATE",
                                 method = "COT",
                                 options = list(lambda = 0))
#we can also use the dataSim object directly
weightsDS <- calc_weight(x = data,
                                 z = NULL,
                                 estimand = "ATE",
                                 method = "COT",
                                 options = list(lambda = 0))
all.equal(weights@w0, weightsDS@w0)
all.equal(weights@w1, weightsDS@w1)
}

[Package causalOT version 1.0.2 Index]