metalearner_ensemble {DeepLearningCausal}R Documentation

metalearner_ensemble

Description

metalearner_ensemble implements the S-learner and T-learner for estimating CATE using the super learner ensemble method. The super learner in this case includes the following machine learning algorithms: extreme gradient boosting, glmnet (elastic net regression), random forest and neural nets.

Usage

metalearner_ensemble(
  data,
  cov.formula,
  treat.var,
  meta.learner.type,
  SL.learners = c("SL.glmnet", "SL.xgboost", "SL.ranger", "SL.nnet"),
  nfolds = 5,
  binary.outcome = FALSE
)

Arguments

data

data.frame object of data

cov.formula

formula description of the model y ~ x(list of covariates)

treat.var

string for the name of treatment variable.

meta.learner.type

string specifying is the S-learner and "T.Learner" for the T-learner model.

SL.learners

vector for super learner ensemble that includes extreme gradient boosting, glmnet, random forest, and neural nets.

nfolds

number of folds for cross-validation. Currently supports up to 5 folds.

binary.outcome

logical specifying predicted outcome variable will take binary values or proportions.

Value

metalearner_ensemble of predicted outcome values and CATEs estimated by the meta learners for each observation.

Examples

# load dataset
data(exp_data)
#load SuperLearner package
library(SuperLearner)
# estimate CATEs with S Learner
set.seed(123456)
slearner <- metalearner_ensemble(cov.formula = support_war ~ age +
                                  income + employed + job_loss,
                                data = exp_data,
                                treat.var = "strong_leader",
                                meta.learner.type = "S.Learner",
                                SL.learners = c("SL.glm"),
                                nfolds = 5,
                                binary.outcome = FALSE)
print(slearner)


# estimate CATEs with T Learner
set.seed(123456)
tlearner <- metalearner_ensemble(cov.formula = support_war ~ age + income +
                                  employed  + job_loss,
                                  data = exp_data,
                                  treat.var = "strong_leader",
                                  meta.learner.type = "T.Learner",
                                  SL.learners = c("SL.xgboost","SL.ranger",
                                               "SL.nnet"),
                                  nfolds = 5,
                                  binary.outcome = FALSE)

print(tlearner)
                                  


[Package DeepLearningCausal version 0.0.104 Index]