Estimates the average treatment effect by weighting outcomes with the inverse of the estimated propensity score \(e(x) = P(T = 1 | X = x)\): $$\widehat{ATE} = \frac{1}{n} \sum_i \frac{T_i Y_i}{\hat e(X_i)} - \frac{1}{n} \sum_i \frac{(1 - T_i) Y_i}{1 - \hat e(X_i)}$$ The propensity score is estimated with any mlr3 classification learner.

ate_ipw(
  data,
  outcome = "y",
  treatment = "t",
  ps_learner,
  covariates = NULL,
  folds = 1,
  ps_trim = NULL
)

Arguments

data

A data.frame with the outcome, treatment and covariates.

outcome

Name of the outcome column. Default "y".

treatment

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

ps_learner

An mlr3 classification learner used as the propensity score model, e.g. mlr3::lrn("classif.log_reg"). Its predict type is set to "prob" automatically.

covariates

Optional character vector of covariate columns. Defaults to all columns except the outcome and the treatment.

folds

Number of cross-fitting folds for the propensity model. 1 (the default) fits and predicts in-sample; values greater than 1 use out-of-fold predictions, which reduces overfitting bias when using flexible learners.

ps_trim

Optional trimming for the estimated propensity scores. Either a single value a (clips to [a, 1 - a]) or a length-2 range. NULL (default) applies no trimming.

Value

An object of class "causalmlr_ate"; see ate_naive().

See also

Examples

# \donttest{
library(mlr3)
data(sodium)
ate_ipw(sodium, outcome = "bp", treatment = "sodium",
        ps_learner = lrn("classif.rpart"))
#> ATE estimate - Inverse propensity weighting 
#>   Estimate:  2.466
#>   Std. error: 2.668 
#>   95% CI:    [-2.762, 7.695]
#>   N:         10000
# }