data(LL)
# cem match: automatic bin choice
mat <- cem(treatment="treated",data=LL, drop="re78")
mat
mat$k2k
# ATT estimate
att(mat, re78~treated, data=LL)
# reduce the match into k2k using euclidean distance within cem strata
mat2 <- k2k(mat, LL, "euclidean", 1)
mat2
mat2$k2k
# ATT estimate after k2k
att(mat2, re78~treated, data=LL)
# example with missing data
# using multiply imputated data
# we use Amelia for multiple imputation
if(require(Amelia)){
data(LL)
n <- dim(LL)[1]
k <- dim(LL)[2]
# we generate missing values in 30% of the rows of LL data
# randomly in one colum per row
LL1 <- LL
idx <- sample(1:n, .3*n)
invisible(sapply(idx, function(x) LL1[x,sample(2:k,1)] <<- NA))
imputed <- amelia(LL1)[1:5]
mat <- cem("treated", datalist=imputed, data=LL1, drop="re78")
print(mat)
att(mat, re78 ~ treated, data=imputed)
}Run the code above in your browser using DataLab