DDcomb: Double demeaning estimator with treatment and outcome...

View source: R/combFun.R

DDcombR Documentation

Double demeaning estimator with treatment and outcome learners

Description

Double demeaning estimator with treatment and outcome learners

Usage

DDcomb(
  Y,
  Z,
  X,
  interZ = formula(~1),
  ID,
  data,
  library = c("glm", "deeplearning"),
  crossFitting = FALSE,
  K = 5,
  mCrossFit = 100
)

Arguments

Y

continuous outcome variable

Z

binary treatment indicator, 1 - treatment, 0 - control

X

vector, matrix, or dataframe containing measured confounders

interZ

formula that contains the variables that "interact" with the treatment. "1" will be always added. The default is no interaction, i.e., formula = formula(~1).

ID

cluster identifier

data

dataframe containing the variables in the model

library

character vector of prediction algorithms. The available methods are glm, deeplearning, gbm, and randomForests. The default methods are glm and deeplearning.

crossFitting

whether to do cross fitting. The default is FALSE, and currently it is not available.

K

number of folds. The default is 5, and currently it is not available.

mCrossFit

number of cross fitting. The default is FALSE, and currently it is not available.

Value

An DDcomb with the following elements:

coef.ER

vector of the coefficients for prediction algorithms in the demeaned treatment model

coef.OR

vector of the coefficients for prediction algorithms in the demeaned outcome model

Estimate

estimates and standard errors of treatment effects

Z.hat

final weighted prediction for the demeaned treatment

Y1.hat

final weighted prediction for the demeaned outcome among treated units

Y0.hat

final weighted prediction for the demeaned outcome among control units

Z.hats

all the predictions for the demeaned treatment from prediction algorithms

Y1.hats

all the predictions for the demeaned outcome among treated units from prediction algorithms

Y0.hats

all the predictions for the demeaned outcome among control units from prediction algorithms

Examples

# two-level data
DDcomb.rlst <- DDcomb(Y=twolevel_data$Y, Z=twolevel_data$Z, interZ=(~ W1),
 X=twolevel_data[, c("X1", "X2", "X3", "W1")], ID=twolevel_data$id,
 library="glm", data=twolevel_data)
summary(DDcomb.rlst)


# two-level data with default algorithms
DDcomb.rlst2 <- DDcomb(Y=twolevel_data$Y, Z=twolevel_data$Z, interZ=(~ W1),
 X=twolevel_data[, c("X1", "X2", "X3", "W1")], ID=twolevel_data$id,
 library=c("glm", "deeplearning"), data=twolevel_data)
summary(DDcomb.rlst2)

# cross-classified data with default algorithms
DDcomb.rlst3 <- DDcomb(Y=crossclassified_data$Y, Z=crossclassified_data$Z, interZ=(~ W1),
 X=crossclassified_data[, c("X1", "X2", "X3", "W1", "Q1")], ID=crossclassified_data$f12id,
 library=c("glm", "deeplearning"), data=crossclassified_data)
summary(DDcomb.rlst3)


youmisuk/CURobustML documentation built on Sept. 11, 2022, 11:04 a.m.