Skip to contents

Balancing weights for a binary, multi-category or continuous treatment under the method names and rules of WeightIt (Greifer 2024), with no call into it: "glm" (a propensity model: any binomial link, maximum likelihood, Firth's bias reduction, ridge, lasso or an elastic net; multinomial or cumulative-link for more than two levels; the density-ratio generalised propensity weight for a continuous treatment), "ebal" (entropy balancing, exact moment balance), "ipt" (inverse probability tilting) and "cbps" (the covariate balancing propensity score, just- or over-identified). The weights each estimand takes from a propensity score follow WeightIt's get_w_from_ps: "ATE", "ATT", "ATC", "ATO", "ATM" and "ATOS" for a binary treatment, "ATE", "ATT", "ATC", "ATO" and "ATM" for a multi-category one.

Usage

morie_weightit(
  data,
  treatment,
  covariates,
  method = c("glm", "ebal", "ipt", "cbps"),
  estimand = "ATE",
  focal = NULL,
  link = "logit",
  ps_model = "mle",
  lambda = 1,
  alpha = 1,
  sampling_weights = NULL,
  stabilize = FALSE,
  moments = 1L,
  int = FALSE,
  over = FALSE,
  density = "normal",
  bw = "nrd0",
  adjust = 1,
  ordinal = FALSE,
  d_moments = 1L
)

# S3 method for class 'morie_weightit'
print(x, ...)

Arguments

data

A data frame.

treatment

Name of the treatment column. Two distinct values make a binary treatment; a factor, character, or an integer-valued column with at most ten levels a multi-category one; any other numeric column a continuous one.

covariates

Character vector of covariate names; non-numeric columns enter as dummies.

method

One of "glm", "ebal", "ipt", "cbps".

estimand

The target: see Details for what each method and treatment type accept. Ignored for a continuous treatment.

focal

For a multi-category treatment with estimand "ATT" or "ATC", the level the others are weighted to.

The propensity model's link ("logit", "probit", "cloglog", "loglog", "cauchit", "log", "clog", "identity"); for a continuous treatment the Gaussian link.

ps_model

For a binary "glm": "mle", "firth", "ridge", "lasso" or "elasticnet".

lambda, alpha

The penalty and the elastic-net mixing weight of a penalised propensity model.

sampling_weights

Optional sampling weights (a numeric vector or a column name); the balancing weights multiply them.

stabilize

For a binary or multi-category treatment, multiply the weights by the marginal probability of the unit's level. A continuous treatment's weights are stabilised already.

moments, int

For "ebal", balance powers up to moments of the non-binary covariates and, with int, all pairwise products.

over

For "cbps", the over-identified (GMM) estimator.

density, bw, adjust

For a continuous "glm", the density of the standardised residuals ("normal", "laplace", "t_<df>", "kernel" or a function) and the kernel bandwidth arguments.

ordinal

Treat a multi-category treatment as ordered and fit a cumulative-link model.

d_moments

For a continuous "ebal", balance powers up to this order of the treatment.

x

A morie_weightit object.

...

Ignored.

Value

A list of class morie_weightit: weights; ps (the propensity scores, a matrix of them for a multi-category treatment, the fitted treatment for a continuous one, NULL for "ebal"); treatment_type; method; estimand; focal; ess (the effective sample size); and, for an over-identified "cbps", objective, the GMM criterion as a function of a propensity score vector.

Details

Each method's estimands: "glm" every one above; "ebal" "ATE", "ATT", "ATC"; "ipt" "ATE", "ATT", "ATC"; "cbps" (binary only) "ATE", "ATT", "ATC", "ATO". A continuous treatment takes "glm" or "ebal".

References

Greifer N (2024). WeightIt: Weighting for Covariate Balance in Observational Studies. Hainmueller J (2012). Entropy balancing for causal effects. Political Analysis 20(1). Graham BS, Pinto CC, Egel D (2012). Inverse probability tilting. Review of Economic Studies 79(3). Imai K, Ratkovic M (2014). Covariate balancing propensity score. JRSS-B 76(1). Kosmidis I, Firth D (2009). Bias reduction in exponential family nonlinear models. Biometrika 96(4).

Examples

set.seed(1)
d <- data.frame(t = rbinom(80, 1, 0.4), x = rnorm(80), g = sample(c("a", "b"), 80, TRUE))
w <- morie_weightit(d, "t", c("x", "g"), method = "ebal", estimand = "ATT")
round(w$ess, 2)
#> [1] 77.77
d$a <- rnorm(80, d$x)
morie_weightit(d, "a", "x", method = "glm")$ess
#> [1] 54.62552