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)
}
Run the code above in your browser using DataLab