| DD | R Documentation |
Double demeaning estimator
DD(Y, Z, interZ = formula(~1), ID, Z.hat, Y0.hat, data)
Y |
continuous outcome variable |
Z |
binary treatment indicator, 1 - treatment, 0 - control |
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 |
Z.hat |
treatment prediction from |
Y0.hat |
outcome prediction among untreated units from |
data |
dataframe containing the variables in the model |
estimates and standard errors
DDcomb.rslt <- 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) # the default algorithms are "glm" and "deeplearning".
# with final predictions
DD(Y=twolevel_data$Y, Z=twolevel_data$Z, interZ=(~ W1), ID=twolevel_data$id,
Z.hat=DDcomb.rslt$Z.hat, Y0.hat=DDcomb.rslt$Y0.hat, data=twolevel_data)
DDPRcomb.rslt <- DDPRcomb(Y=twolevel_data$Y, Z=twolevel_data$Z, interZ=(~ W1),
X=twolevel_data[, c("X1", "X2", "X3", "W1")], ID=twolevel_data$id, data=twolevel_data)
# with final predictions
DD(Y=twolevel_data$Y, Z=twolevel_data$Z, interZ=(~ W1), ID=twolevel_data$id,
Z.hat=DDPRcomb.rslt$Z.hat, Y0.hat=DDPRcomb.rslt$Y0.hat, data=twolevel_data)
# with predictions from glm with fixed effects of clusters
DD(Y=twolevel_data$Y, Z=twolevel_data$Z, interZ=(~ W1), ID=twolevel_data$id,
Z.hat=DDPRcomb.rslt$Z.hats$Ztest.hat_glm_1, Y0.hat=DDPRcomb.rslt$Y0.hats$Y0test.hat_glm_1,
data=twolevel_data)
# with predictions from deep learning
DD(Y=twolevel_data$Y, Z=twolevel_data$Z, interZ=(~ W1), ID=twolevel_data$id,
Z.hat=DDPRcomb.rslt$Z.hats$Ztest.hat_dl, Y0.hat=DDPRcomb.rslt$Y0.hats$Y0test.hat_dl,
data=twolevel_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.