Skip to contents

Estimates the probability of treatment via logistic regression or gradient boosting on a set of covariates. Both run natively.

Usage

morie_matching_estimate_propensity(
  data,
  treatment,
  covariates,
  model = "logistic",
  max_iter = 1000
)

Arguments

data

Data frame.

treatment

Name of the binary treatment column (0/1).

covariates

Character vector of covariate names.

model

One of "logistic" (default) or "gbm" (native gradient boosting, see Details).

max_iter

Maximum iterations for logistic regression.

Value

A numeric vector of propensity scores aligned to the rows of data (after dropping NAs in treatment or covariates); the names of the vector are the row names of the retained rows.

Details

model = "gbm" is native Bernoulli-deviance gradient boosting with the settings this function always used for gbm: 100 trees, interaction.depth = 3 (three best-first splits per tree), shrinkage 0.1 and at least 10 observations per node, leaves set by a Newton step on the binomial deviance. It differs from a default gbm::gbm() call in one respect: no row subsampling (gbm's bag.fraction = 1), so the scores are deterministic and need no seed. Factor covariates enter through their treatment-contrast dummy columns. Cross-validated against gbm (with bag.fraction = 1) in the tests; gbm is not needed at run time.

References

Rosenbaum, P. R., & Rubin, D. B. (1983). The central role of the propensity score in observational studies for causal effects. Biometrika, 70(1), 41–55.

Friedman, J. H. (2001). Greedy function approximation: a gradient boosting machine. Annals of Statistics, 29(5), 1189–1232.

Examples

set.seed(1)
df <- data.frame(d = rbinom(200, 1, 0.4),
                 x1 = rnorm(200), x2 = rnorm(200))
ps <- morie_matching_estimate_propensity(df, "d", c("x1", "x2"))
ps_gbm <- morie_matching_estimate_propensity(df, "d", c("x1", "x2"),
                                             model = "gbm")