-
-
Save josealvarez97/3149a44835d5b7b06dbbcb3c7067320f to your computer and use it in GitHub Desktop.
Breakout1
This file contains 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
# If you are copy/pasting this to an R Notebook, select "Raw" from the GitHub page before you copy. | |
# Replication file of Section 5 in | |
# Iacus, King, Porro (2011), Multivariate Matching Methods | |
# That Are Monotonic Imbalance Bounding, JASA, V 106, N. 493, | |
# p. 345-361 | |
foo <- read.csv(url("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00089202-1711/daughters.csv")) | |
# Table 1 in Ebonya | |
# Indep. vars | |
# anygirls: Any female children | |
# ngirls: Number of female children | |
# totchi: Total number of children | |
# white: White=1, 0 otherwise | |
# female: Female=1, 0 otherwise | |
# age: age | |
# srvlng: Service length (years) | |
# reg1 - reg9 are regional binary variables | |
# binary religious variables: none, Protestant, Catholic, OtherC, OtherR | |
# binary party variables: Dems, Repubs, OthParty | |
# DEPENDENT VARIABLE: nowtot | |
#### BREAKOUT 1 #### | |
## Perform genetic matching with the following variables: | |
## Dems, Repubs, Christian, age, srvlng, demvote | |
## Tr = hasgirls | |
## Set pop.size = 100, set nboots = 250... complete the instructions below... | |
set.seed(2324); genout <- GenMatch(Tr = , X = cbind(), pop.size = , nboots = ) | |
mout <- Match(Tr = , X = cbind(), Weight.matrix = ) | |
MatchBalance( ~ , match.out = ) | |
## If you obtain really high balance, consider rerunning with M = 2 or 3... | |
## If/when you are satisfied by balance achieved, then rerun Match() with Y included | |
## and obtain the treatment effect estimate, the standard error, and the confidence interval. | |
mout <- Match(Y = , Tr = , | |
X = cbind(), Weight.matrix = ) | |
summary(mout) | |
## If you get to the end and have extra time, you can try changing X (remember to change | |
## it in GenMatch, in Match, and also in the formula for MatchBalance(). | |
## For example, you could try to control more finely for religion. You could try to control | |
## for race (e.g., binary "white" variable), or for region (reg1, reg2, etc.) | |
## IMPORTANT: SAVE YOUR mout object! | |
## Follow this protocol: save(object_name, file = "object_filename") to save to working directory | |
## e.g., if you have an object named mmm, save(mmm, file = "mmm") | |
## To retrieve your object, you would type: load("object_filename") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`
https://gist.github.com/diamonaj/555eb605698b055fa76c1404c6c44bb7
If you are copy/pasting this to an R Notebook, select "Raw" from the GitHub page before you copy.
Replication file of Section 5 in
Iacus, King, Porro (2011), Multivariate Matching Methods
That Are Monotonic Imbalance Bounding, JASA, V 106, N. 493,
p. 345-361
foo <- read.csv(url("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00089202-1711/daughters.csv"))
Table 1 in Ebonya
Indep. vars
anygirls: Any female children
ngirls: Number of female children
totchi: Total number of children
white: White=1, 0 otherwise
female: Female=1, 0 otherwise
age: age
srvlng: Service length (years)
reg1 - reg9 are regional binary variables
binary religious variables: none, Protestant, Catholic, OtherC, OtherR
binary party variables: Dems, Repubs, OthParty
DEPENDENT VARIABLE: nowtot
BREAKOUT 1
Perform genetic matching with the following variables:
Dems, Repubs, Christian, age, srvlng, demvote
Tr = hasgirls
Set pop.size = 20, set nboots = 200... complete the instructions below...
set.seed(2324);
genout <- GenMatch(Tr = foo$hasgirls, X = cbind(foo$Dems, foo$Repubs, foo$Christian, foo$age, foo$srvlng, foo$demvote), pop.size = 20, nboots = 200)
mout <- Match(Tr = foo$hasgirls, X = cbind(foo$Dems, foo$Repubs, foo$Christian, foo$age, foo$srvlng, foo$demvote), Weight.matrix = genout)
MatchBalance( foo$hasgirls ~ foo$Dems + foo$Repubs + foo$Christian + foo$age + foo$srvlng + foo$demvote + match.out = mout)
If you obtain really high balance, consider rerunning with M = 2 or 3...
If/when you are satisfied by balance achieved, then rerun Match() with Y included
and obtain the treatment effect estimate, the standard error, and the confidence interval.
mout <- Match(Y = foo$nowtot, Tr = foo$hasgirls, X = cbind(foo$Dems, foo$Repubs, foo$Christian, foo$age, foo$srvlng, foo$demvote), Weight.matrix = mout)
summary(mout)
If you get to the end and have extra time, you can try changing X (remember to change
it in GenMatch, in Match, and also in the formula for MatchBalance().
For example, you could try to control more finely for religion. You could try to control
for race (e.g., binary "white" variable), or for region (reg1, reg2, etc.)
IMPORTANT: SAVE YOUR mout object!
Follow this protocol: save(object_name, file = "object_filename") to save to working directory
e.g., if you have an object named mmm, save(mmm, file = "mmm")
To retrieve your object, you would type: load("object_filename")
`