Slearners: S-Learners

S-LearnerR Documentation

S-Learners

Description

S_RF is an implementation of the S-Learner combined with Random Forests (Breiman 2001).

S_BART is an implementation of the S-Learner with Bayesian Additive Regression Trees (Chipman et al. 2010).

Usage

S_RF(
  feat,
  tr,
  yobs,
  nthread = 0,
  verbose = TRUE,
  mu.forestry = list(relevant.Variable = 1:ncol(feat), ntree = 1000, replace = TRUE,
    sample.fraction = 0.9, mtry = ncol(feat), nodesizeSpl = 1, nodesizeAvg = 3,
    nodesizeStrictSpl = 3, nodesizeStrictAvg = 1, splitratio = 1, middleSplit = FALSE,
    OOBhonest = TRUE)
)

S_BART(
  feat,
  tr,
  yobs,
  ndpost = 1200,
  ntree = 200,
  nthread = 1,
  verbose = FALSE,
  mu.BART = list(sparse = FALSE, theta = 0, omega = 1, a = 0.5, b = 1, augment = FALSE,
    rho = NULL, usequants = FALSE, cont = FALSE, sigest = NA, sigdf = 3, sigquant = 0.9,
    k = 2, power = 2, base = 0.95, sigmaf = NA, lambda = NA, numcut = 100L, nskip = 100L)
)

Arguments

feat

A data frame containing the features.

tr

A numeric vector with 0 for control and 1 for treated variables.

yobs

A numeric vector containing the observed outcomes.

nthread

Number of threads which should be used to work in parallel.

verbose

TRUE for detailed output, FALSE for no output.

mu.forestry

A list containing the hyperparameters for the forestry package that are used in \hat μ_0. These hyperparameters are passed to the forestry package.

ndpost

Number of posterior draws.

ntree

Number of trees.

mu.BART

hyperparameters of the BART function. Use ?BART::mc.wbart for a detailed explanation of their effects.

Details

In the S-Learner, the outcome is estimated using all of the features and the treatment indicator without giving the treatment indicator a special role. The predicted CATE for an individual unit is then the difference between the predicted values when the treatment assignment indicator is changed from control to treatment:

  1. Estimate the joint response function

    μ(x, w) = E[Y | X = x, W = w]

    using the base learner. We denote the estimate as \hat μ.

  2. Define the CATE estimate as

    τ(x) = \hat μ_1(x, 1) - \hat μ_0(x, 0).

Value

Object of class S_RF. It should be used with one of the following functions EstimateCATE, CateCI, and CateBIAS. The object has the following slots:

feature_train

A copy of feat.

tr_train

A copy of tr.

yobs_train

A copy of yobs.

m_0

An object of class forestry that is fitted with the observed outcomes of the control group as the dependent variable.

m_1

An object of class forestry that is fitted with the observed outcomes of the treated group as the dependent variable.

hyperparameter_list

A list containting the hyperparameters of the three random forest algorithms used.

creator

Function call of S_RF. This is used for different bootstrap procedures.

Author(s)

Soeren R. Kuenzel

References

  • Sören Künzel, Jasjeet Sekhon, Peter Bickel, and Bin Yu (2017). MetaLearners for Estimating Heterogeneous Treatment Effects using Machine Learning. https://www.pnas.org/content/116/10/4156

  • Sören Künzel, Simon Walter, and Jasjeet Sekhon (2018). Causaltoolbox—Estimator Stability for Heterogeneous Treatment Effects. https://arxiv.org/pdf/1811.02833.pdf

  • Sören Künzel, Bradly Stadie, Nikita Vemuri, Varsha Ramakrishnan, Jasjeet Sekhon, and Pieter Abbeel (2018). Transfer Learning for Estimating Causal Effects using Neural Networks. https://arxiv.org/pdf/1808.07804.pdf

See Also

Other metalearners: DR-Learner, M-Learner, T-Learner, X-Learner

Other metalearners: DR-Learner, M-Learner, T-Learner, X-Learner

Examples

require(causalToolbox)

# create example data set
simulated_experiment <- simulate_causal_experiment(
  ntrain = 1000,
  ntest = 1000,
  dim = 10
)
feat <- simulated_experiment$feat_tr
tr <- simulated_experiment$W_tr
yobs <- simulated_experiment$Yobs_tr
feature_test <- simulated_experiment$feat_te

# create the CATE estimator using Random Forests (RF)
xl_rf <- X_RF(feat = feat, tr = tr, yobs = yobs)
tl_rf <- T_RF(feat = feat, tr = tr, yobs = yobs)
sl_rf <- S_RF(feat = feat, tr = tr, yobs = yobs)
ml_rf <- M_RF(feat = feat, tr = tr, yobs = yobs)
xl_bt <- X_BART(feat = feat, tr = tr, yobs = yobs)
tl_bt <- T_BART(feat = feat, tr = tr, yobs = yobs)
sl_bt <- S_BART(feat = feat, tr = tr, yobs = yobs)
ml_bt <- M_BART(feat = feat, tr = tr, yobs = yobs)
  
cate_esti_xrf <- EstimateCate(xl_rf, feature_test)

# evaluate the performance.
cate_true <- simulated_experiment$tau_te
mean((cate_esti_xrf - cate_true) ^ 2)
## Not run: 
# create confidence intervals via bootstrapping. 
xl_ci_rf <- CateCI(xl_rf, feature_test, B = 500)

## End(Not run)

forestry-labs/causalToolbox documentation built on Feb. 6, 2023, 11:27 p.m.