Skip to contents

The T-learner fits separate outcome models on treated and control units, then predicts the counterfactual for each unit: \(\widehat{CATE}_i = \hat{\mu}_1(X_i) - \hat{\mu}_0(X_i)\).

Usage

morie_estimate_cate(
  data,
  treatment,
  outcome,
  covariates,
  propensity_col = NULL,
  outcome_model = c("linear", "logistic"),
  meta_learner = c("t_learner", "s_learner")
)

Arguments

data

A data frame.

treatment

Name of the binary treatment column.

outcome

Name of the outcome column.

covariates

Character vector of covariate names.

propensity_col

Optional: name of a pre-computed propensity score column.

outcome_model

Family for the outcome model: "linear" or "logistic".

meta_learner

"t_learner" (default) or "s_learner".

Value

Numeric vector of per-unit CATE estimates.

Details

The S-learner fits one model with treatment as a feature.

For random-forest CATE estimation prefer grf::causal_forest (richer heterogeneity, honest sample splitting).

Examples

morie_estimate_cate(
  data = data.frame(
    t = stats::rbinom(100, 1, 0.4),
    y = stats::rbinom(100, 1, 0.3), x1 = stats::rnorm(100),
    x2 = stats::rnorm(100)
  ), treatment = "t", outcome = "y",
  covariates = c("x1", "x2")
)
#>   [1]  2.769262e-01  1.191874e-01  3.284381e-01  1.573232e-01 -1.583333e-01
#>   [6] -1.896366e-01  7.291944e-02 -2.382879e-01 -2.016914e-02  2.930165e-01
#>  [11]  3.400819e-01  3.035114e-01 -6.526880e-02 -5.250864e-02  6.352489e-02
#>  [16]  1.285275e-01 -1.666681e-01  4.383367e-01  1.119128e-01 -4.471060e-02
#>  [21]  2.218178e-01 -8.517922e-02 -1.252241e-02  1.690615e-01 -1.366705e-01
#>  [26] -2.584307e-02  2.923383e-01  4.350664e-01  3.717662e-02  4.917438e-01
#>  [31]  1.081183e-01 -2.007286e-01  2.577374e-01 -1.994083e-01 -1.087121e-02
#>  [36]  2.251915e-01 -3.275402e-01  4.023406e-01 -7.865019e-03 -6.115931e-02
#>  [41]  1.982172e-01  4.334646e-01  3.838236e-01  2.641491e-01  2.397277e-01
#>  [46] -3.461637e-02  3.987534e-01 -9.282062e-02  2.643081e-01  2.221608e-01
#>  [51] -2.112231e-01 -2.495632e-01 -1.054793e-06  4.440436e-01 -2.243111e-01
#>  [56]  7.452735e-02  2.430718e-01  4.317988e-01  3.974921e-01  3.269579e-01
#>  [61]  3.280226e-01 -3.527099e-01 -2.506222e-01  3.238448e-01 -3.177135e-01
#>  [66]  1.976368e-01 -5.081684e-02  3.094229e-01  4.985370e-01 -1.145216e-01
#>  [71]  3.763610e-01  4.467011e-02  2.929457e-01 -4.305922e-01  1.490792e-01
#>  [76]  2.513334e-01  3.915224e-01  7.579912e-02  2.188438e-01  5.920452e-01
#>  [81]  4.684434e-01  1.295353e-01  6.708286e-02  2.184122e-01  2.057565e-01
#>  [86]  4.929701e-02  1.299010e-01  1.120524e-01  2.065055e-01  1.376485e-01
#>  [91] -2.309078e-02  2.710560e-01 -3.904404e-02  2.220864e-01  9.385967e-02
#>  [96]  1.237774e-01  2.773058e-01  2.253498e-01 -1.305173e-01 -1.899976e-01