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
| genout <- GenMatch(Tr=treat, X=X, BalanceMatrix=BalanceMat, estimand="ATT", exact = TRUE, M=1, | |
| pop.size=16, max.generations=10, wait.generations=1) | |
| #The outcome variable | |
| Y=re78/1000 | |
| # | |
| # Now that GenMatch() has found the optimal weights, let's estimate | |
| # our causal effect of interest using those weights | |
| # |
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
| genout <- GenMatch(Tr=treat, X=X, BalanceMatrix=BalanceMat) | |
| #The outcome variable | |
| Y=re78/1000 | |
| # | |
| # Now that GenMatch() has found the optimal weights, let's estimate | |
| # our causal effect of interest using those weights | |
| # | |
| mout <- Match(Y=Y, Tr=treat, X=X, Weight.matrix=genout) |
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
| sink("transcript.txt", split = TRUE) | |
| cat(getwd(), "\n") | |
| rm(list=ls()) | |
| library(foreign) | |
| foo <- read.csv("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00087718-6996/dw-data.csv") | |
| X = cbind(foo$age, foo$education, foo$black, foo$hispanic, foo$married, foo$nodegree, foo$re75, foo$re74) |
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
| # https://tinyurl.com/y9syodxg | |
| rm(list=ls()) | |
| library(Matching | |
| ) | |
| library(foreign) | |
| foo <- read.csv("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00087718-6996/dw-data.csv") | |
| X = cbind(foo$age, foo$education, foo$black, foo$re75, foo$re74) |
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
| # If you are copy/pasting this to an R Notebook, select "Raw" from the GitHub page before you copy. | |
| # Check the sensitivity of your Genetic Matching results, using "hlsens" and "psens" in the rbounds library. | |
| # You must load the library first. | |
| # You should load your mout2 object... e.g., load("mout2") | |
| ## Here is the working matching code, in case it's helpful: | |
| foo <- read.csv(url("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00089202-1711/daughters.csv")) | |
| which.two.or.more.girls <- which(foo$ngirls >= 2 & foo$nboys == 0) |
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
| # If you are copy/pasting this to an R Notebook, select "Raw" from the GitHub page before you copy. | |
| # 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 |
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
| # 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 |
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
| ######### RUN THE CODE BELOW IN R. R-STUDIO IS THE RECOMMENDED IDE. BOTH R AND R-STUDIO ARE FREE. | |
| ######### QUESTIONS SHOULD BE POSTED TO PIAZZA | |
| ######### THE ACTUAL ASSIGNMENT BEGINS ON LINE 71 (where it says "ASSIGNMENT 1...") | |
| ### Multilateral Development Institution Data | |
| foo <- read.csv("https://tinyurl.com/yb4phxx8") # read in the data | |
| # column names | |
| names(foo) |
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
| PEACEKEEPING WORKOUT (based on King, Gary;Zeng, Langche, 2007, | |
| "Replication data for: When Can History be Our Guide? | |
| The Pitfalls of Counterfactual Inference", | |
| https://hdl.handle.net/1902.1/DXRXCFAWPK, | |
| Harvard Dataverse, V4, | |
| UNF:3:DaYlT6QSX9r0D50ye+tXpA== [fileUNF] ) | |
| # CONSIDER USING THE JUPYTER NOTEBOOK WITH R-SERVER KERNEL (NEVER R-SAGE KERNEL) | |
| foo_orig <- read.csv("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00086677-3767/peace.csv") |
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
| PEACEKEEPING WORKOUT (based on King, Gary;Zeng, Langche, 2007, | |
| "Replication data for: When Can History be Our Guide?) | |
| # CONSIDER USING THE JUPYTER NOTEBOOK WITH R-SERVER KERNEL (NEVER R-SAGE KERNEL) | |
| rm(list=ls()) # WARNING: THIS DELETES EVERYTHING IN YOUR R WORKSPACE | |
| detach(foo) # probably unnecessary, but just in case you had it attached... | |
| library(Matching) | |
| foo <- read.csv("https://course-resources.minerva.kgi.edu/uploaded_files/mke/00086677-3767/peace.csv") | |