Created
November 14, 2022 15:12
-
-
Save diamonaj/0b76cda2b48cd5a48daa87ba9f9e7637 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From class on Monday, Nov 14 | |
# Switching to the OBSERVATIONAL Lalonde data set | |
# do genetic matching using the observational lalonde data | |
# use a caliper = to 0.1 standard deviations for every x. | |
library(Matching) | |
lalonde <- read.csv("https://tinyurl.com/st9n3dl") | |
X = cbind(lalonde$age, lalonde$educ, lalonde$black, lalonde$hisp, lalonde$married, lalonde$nodegr, lalonde$u74, lalonde$u75, lalonde$re75, lalonde$re74) | |
# | |
genout <- GenMatch(Tr=lalonde$treat, X=X, BalanceMatrix=X, M=1, | |
pop.size=20, max.generations=10, | |
caliper = 0.1, | |
wait.generations=10) | |
mout <- Match(Tr=lalonde$treat, X=X, caliper = 0.1, | |
Weight.matrix=genout) | |
summary(mout) | |
# Has good balance been obtained? | |
# | |
#Let's determine if balance has actually been obtained on the variables of interest | |
# | |
mb <- MatchBalance(treat~age +educ+black+ hisp+ married+ | |
nodegr+ u74+ u75+ | |
re75+ re74+ I(re74*re75), data = lalonde, | |
match.out=mout, nboots=500) | |
mb$AMsmallest.p.value | |
mb$AMsmallestVarName | |
treated_units <- lalonde[mout$index.treated,] | |
control_units <- lalonde[mout$index.control,] | |
matched_data <- rbind(treated_units,control_units) | |
unit_level_weights <- mout$weights | |
dim(matched_data) | |
library(quantreg) | |
reg1 <- rq(re78 ~ treat, data = matched_data, tau = 0.5) | |
summary(reg1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment