calc_weight | R Documentation |
Estimate causal weights
calc_weight(
x,
z,
estimand = c("ATC", "ATT", "ATE"),
method = supported_methods(),
options = NULL,
weights = NULL,
...
)
x |
A numeric matrix of covariates. You can also pass an object of class dataHolder or DataSim, which will make argument |
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 |
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 |
... |
Not used at this time. |
We detail some of the particulars of the function arguments below.
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.
This is equivalent to COT with an infinite penalty parameter, options(lambda = Inf)
. Uses the same solver and options as COT, cotOptions().
This is equivalent to COT with a penalty parameter = 0, options(lambda = 0)
. Uses the same solver and options as COT, cotOptions().
The SCM method is equivalent to an OT problem from a different angle. See scmOptions()
.
This method balances chosen functions of the covariates specified in the data argument, x
. See entBWOptions()
for more details. Hainmueller (2012).
Entropy Balancing Weights with a different penalty parameter, proposed by Zuizarreta (2012). See sbwOptions()
for more details
The CBPS method of Imai and Ratkovic. Options argument is passed to the function CBPS().
The main methods historically for implementing inverse probability weights. Options are passed directly to the glm
function from R
.
An object of class causalWeights
estimate_effect()
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.