├── Lecture Notes ├── 1 - Statistical Preliminaries.pdf ├── 2 - Causation and Experiments.pdf ├── 3 - Internal Validity in Experiments.pdf ├── 4 - Inference and External Validity in Experiments.pdf ├── 5 - Selection on Observables (Matching and Regression).pdf ├── 6 - Instrumental Variables I.pdf ├── 7 - Instrumental Variables II.pdf ├── 8 - Regression Discontinuity.pdf ├── 9 - Difference-in-Differences.pdf └── x10 - Synthetic Control.pdf ├── README.md ├── Syllabus.pdf ├── Weekly R Assignments - Code ├── Code - Weekly Assignment 1.R ├── Code - Weekly Assignment 2.R ├── Code - Weekly Assignment 3.R ├── Code - Weekly Assignment 4.R ├── Code - Weekly Assignment 5.R ├── Code - Weekly Assignment 6.R ├── Code - Weekly Assignment 7.R ├── Code - Weekly Assignment 8.R ├── Code - Weekly Assignment 9.R └── Code - Weekly Assignment x10.R ├── Weekly R Assignments - Datasets ├── Stokes.Rda ├── Stokes_fe.Rda ├── africa.RDa ├── benin.Rda ├── experiment.Rda ├── fishdata.csv ├── guangreen.Rda ├── hajjdata.Rda ├── islamic.csv ├── malesky.Rda ├── star.Rda └── t4data.Rda ├── Weekly R Assignments - Solutions ├── Problem Set 1 - Solutions.pdf ├── Problem Set 2 - Solutions.pdf ├── Problem Set 3 - Solutions.pdf ├── Problem Set 4 - Solutions.pdf ├── Problem Set 5 - Solutions.pdf ├── Problem Set 6 - Solutions.pdf ├── Problem Set 7 - Solutions.pdf ├── Problem Set 8 - Solutions.pdf ├── Problem Set 9 - Solutions.pdf ├── Problem Set x10 - Solutions.pdf └── h └── Weekly R Assignments ├── Problem Set 1_stats intro.pdf ├── Problem Set 2_experiments I.pdf ├── Problem Set 3_experiments II.pdf ├── Problem Set 4_experiments III.pdf ├── Problem Set 5_matching.pdf ├── Problem Set 6_instrumental variables I.pdf ├── Problem Set 7_instrumental variables II.pdf ├── Problem Set 8_regression discontinuity.pdf ├── Problem Set 9_difference in differences.pdf └── xProblem Set 10_synthetic control.pdf /Lecture Notes/1 - Statistical Preliminaries.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/1 - Statistical Preliminaries.pdf -------------------------------------------------------------------------------- /Lecture Notes/2 - Causation and Experiments.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/2 - Causation and Experiments.pdf -------------------------------------------------------------------------------- /Lecture Notes/3 - Internal Validity in Experiments.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/3 - Internal Validity in Experiments.pdf -------------------------------------------------------------------------------- /Lecture Notes/4 - Inference and External Validity in Experiments.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/4 - Inference and External Validity in Experiments.pdf -------------------------------------------------------------------------------- /Lecture Notes/5 - Selection on Observables (Matching and Regression).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/5 - Selection on Observables (Matching and Regression).pdf -------------------------------------------------------------------------------- /Lecture Notes/6 - Instrumental Variables I.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/6 - Instrumental Variables I.pdf -------------------------------------------------------------------------------- /Lecture Notes/7 - Instrumental Variables II.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/7 - Instrumental Variables II.pdf -------------------------------------------------------------------------------- /Lecture Notes/8 - Regression Discontinuity.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/8 - Regression Discontinuity.pdf -------------------------------------------------------------------------------- /Lecture Notes/9 - Difference-in-Differences.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/9 - Difference-in-Differences.pdf -------------------------------------------------------------------------------- /Lecture Notes/x10 - Synthetic Control.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Lecture Notes/x10 - Synthetic Control.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Causal-Inference-for-Beginning-Undergraduates 2 | An introductory course on causal inference in the social sciences, that I teach annually at UCL. Designed for undergraduate students with only a working knowledge of R, statistical theory and multiple regression (i.e., 1-2 semesters of a standard sequence). It would also be suitable (but probably too light on technical details) for masters or beginner PhD students. The course is as light as possible on maths, but heavy on intuition and practical examples; matrix notation is not used. The aim is to explain both the statistical theory but also the practicalities and ideas behind causal research designs. Students are taught to design and implement their own studies, and to critique existing papers. The examples are drawn primarily from economics and political science, with a little epidemiology thrown in too. 3 | 4 | This repository contains detailed typed lecture notes, as well as computer exercises in R with solutions and datasets, for a ten-week course covering experiments, matching, instrumental variables, regression discontinuity, difference-in-differences and synthetic control. The lecture notes sometimes reference readings, details of which can be found in the syllabus. I find it helpful to teach lecture 1 to remind students about t tests, omitted variable bias, etc., but it could easily be skipped. 5 | 6 | The weekly exercises almost all involve students replicating results from well-known papers that use the techniques. I've provided worksheets (problem sets) as well as solutions and code for R. At some point I will get round to setting these up properly in R Markdown. The R code is mostly at a very introductory level and therefore suitable for those with minimal background in R. For instance, I do not use tidyverse for this course. My assignments do not tell students how to implement the code, but does provide hints to help them get started with new or tricky pieces of code. 7 | 8 | I am considering trying to publish this as a textbook, and therefore feedback on any errors and potential additions/improvements would be extremely welcome. You are also very welcome to use these materials for your courses. 9 | 10 | Note that lectures 2-4, and some of 6, are designed to be read alongside Gerber and Green's "Field Experiments" textbook and occasionally reproduce equations from the book. Lecture 8 also contains some diagrams that were originally made by Teppei Yamamoto for a similar module at MIT, and some of the material from lecture 9 (including some diagrams) is based on one of his lectures. Having both taken and taught various iterations of causal inference modules at MIT and UCL, it is very possible that some other borrowings have made their way into these lecture notes and exercises: please let me know if anyone else deserves crediting! 11 | 12 | Tom O'Grady (Assistant Professor in Political Science, UCL) 13 | 14 | 14th April 2020 15 | -------------------------------------------------------------------------------- /Syllabus.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Syllabus.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment 1.R: -------------------------------------------------------------------------------- 1 | library(foreign) 2 | 3 | f<-read.csv("fishdata.csv") 4 | 5 | # a 6 | sum(f$MUSLIM) # i 7 | sum(f$MUSLIM)/length(f$MUSLIM) # ii 8 | length(f$GDP90LGN[f$GDP90LGN>3]) # iii 9 | length(f$MUSLIM[f$MUSLIM==1 & f$BRITCOL==1]) # iv 10 | length(f$GDP90LGN[f$GDP90LGN>2.5 | f$GRW7598P>0.6]) # v 11 | f.new <- f[f$MUSLIM==1 & f$OPEC==1,] # vi 12 | 13 | # b 14 | mean(f$FHREVERS[f$MUSLIM==1]) - mean(f$FHREVERS[f$MUSLIM==0]) 15 | summary(lm(FHREVERS ~ MUSLIM, data=f)) 16 | 17 | # d 18 | t.test(f$FHREVERS[f$MUSLIM==1], f$FHREVERS[f$MUSLIM==0]) 19 | 20 | # e 21 | d <- mean(f$FHREVERS[f$MUSLIM==1]) - mean(f$FHREVERS[f$MUSLIM==0]) 22 | 23 | se <- sqrt( 24 | var(f$FHREVERS[f$MUSLIM==1])/length(f$FHREVERS[f$MUSLIM==1]) + 25 | var(f$FHREVERS[f$MUSLIM==0])/length(f$FHREVERS[f$MUSLIM==0]) 26 | ) 27 | 28 | d/se 29 | 30 | # f 31 | length(f$MUSLIM[f$BRITCOL==1 & f$MUSLIM==1]) / sum(f$MUSLIM) 32 | length(f$MUSLIM[f$BRITCOL==1 & f$MUSLIM==0]) / (length(f$MUSLIM)-sum(f$MUSLIM)) 33 | 34 | cor(f$BRITCOL,f$FHREVERS) 35 | 36 | # g 37 | summary(lm(FHREVERS ~ MUSLIM + BRITCOL , data=f)) 38 | 39 | 40 | # h 41 | length(f$MUSLIM[f$OPEC==1 & f$MUSLIM==1]) / sum(f$MUSLIM) 42 | length(f$MUSLIM[f$OPEC==1 & f$MUSLIM==0]) / (length(f$MUSLIM)-sum(f$MUSLIM)) 43 | cor(f$OPEC,f$FHREVERS) 44 | 45 | cor(f$GRW7598P,f$MUSLIM) 46 | cor(f$GRW7598P,f$FHREVERS) 47 | 48 | cor(f$GDP90LGN,f$MUSLIM) 49 | cor(f$GDP90LGN,f$FHREVERS) 50 | 51 | 52 | # i 53 | summary(lm(FHREVERS ~ MUSLIM + BRITCOL + OPEC + GRW7598P + GDP90LGN , data=f)) 54 | 55 | 56 | -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment 2.R: -------------------------------------------------------------------------------- 1 | # Question 1 2 | 3 | load("experiment.Rda") 4 | 5 | # a 6 | mean(a$y1-a$y0) 7 | 8 | # b 9 | set.seed(1) 10 | a$rand <- sample(c(1:100)) 11 | a <- a[order(a$rand),] 12 | a$tr <- c(rep(1,50),rep(0,50)) 13 | 14 | # c 15 | t.test(a$y0[a$tr==1], a$y0[a$tr==0]) 16 | 17 | # d 18 | mean(a$y1[a$tr==1]) - mean(a$y0[a$tr==0]) 19 | 20 | # e 21 | experiment.sim <- function(a){ 22 | a$rand <- sample(c(1:100)) 23 | a <- a[order(a$rand),] 24 | a$tr <- c(rep(1,50),rep(0,50)) 25 | 26 | mean(a$y1[a$tr==1]) - mean(a$y0[a$tr==0]) 27 | } 28 | 29 | sims <- replicate(10000,experiment.sim(a)) 30 | mean(sims) 31 | 32 | # f 33 | experiment.sim2 <- function(a){ 34 | a$rand <- sample(c(1:100)) 35 | a <- a[order(a$rand),] 36 | a$tr <- c(rep(1,50),rep(0,50)) 37 | 38 | mean(a$y0[a$tr==1] - a$y0[a$tr==0]) 39 | } 40 | 41 | sims2 <- replicate(10000,experiment.sim2(a)) 42 | mean(sims2) 43 | 44 | 45 | ############################################# 46 | # Question 2 47 | 48 | load("gerber.Rda") 49 | 50 | # (a) 51 | 52 | mean(g$voting[g$civicduty==1]) - mean(g$voting[g$control==1]) 53 | t.test(g$voting[g$civicduty==1], g$voting[g$control==1]) 54 | 55 | mean(g$voting[g$neighbors==1]) - mean(g$voting[g$control==1]) 56 | t.test(g$voting[g$neighbors==1], g$voting[g$control==1]) 57 | 58 | 59 | # (b) 60 | 61 | t.test(g$sex[g$civicduty==1],g$sex[g$control==1]) 62 | t.test(g$yob[g$civicduty==1],g$yob[g$control==1]) 63 | t.test(g$p2004[g$civicduty==1],g$p2004[g$control==1]) 64 | 65 | t.test(g$sex[g$neighbors==1],g$sex[g$control==1]) 66 | t.test(g$yob[g$neighbors==1],g$yob[g$control==1]) 67 | t.test(g$p2004[g$neighbors==1],g$p2004[g$control==1]) 68 | 69 | 70 | # (c) 71 | 72 | # Subset to only neighbors and control observations 73 | g.reg <- g[g$neighbors==1|g$control==1,] 74 | 75 | #i) 76 | summary(lm(voting ~ neighbors,data=g.reg)) 77 | 78 | #ii) 79 | summary(lm(voting ~ neighbors + sex + yob + p2004,data=g.reg)) 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment 3.R: -------------------------------------------------------------------------------- 1 | load("benin.Rda") 2 | 3 | # (a) 4 | #regress treatment on the covariate 5 | summary(lm(treatment ~ reg.voters,data=b)) 6 | 7 | 8 | # (b) 9 | summary(lm(vote.pop~treatment,data=b)) 10 | 11 | # same 12 | t.test(b$vote.pop[b$treatment==1],b$vote.pop[b$treatment==0]) 13 | 14 | # (c) 15 | summary(lm(vote.pop ~ treatment + factor(block), data=b)) 16 | 17 | 18 | ################################################################## 19 | 20 | # Question 2 21 | 22 | load("star.Rda") 23 | 24 | # (a) 25 | s$treat <- ifelse(s$gkclasstype=="SMALL CLASS",1,0) 26 | 27 | # (b) 28 | t.test(s$gender[s$treat==1],s$gender[s$treat==0]) 29 | t.test(s$race[s$treat==1],s$race[s$treat==0]) 30 | t.test(s$gkfreelunch[s$treat==1],s$gkfreelunch[s$treat==0]) 31 | 32 | 33 | # (c) 34 | ate.reading1 <- lm(gktreadss ~ treat,data=s) 35 | summary(ate.reading1)$coef[2,] 36 | ate.reading2 <- lm(gktreadss ~ treat + factor(gkschid),data=s) 37 | summary(ate.reading2)$coef[2,] 38 | 39 | ate.maths1 <- lm(gktmathss ~ treat,data=s) 40 | summary(ate.maths1)$coef[2,] 41 | ate.maths2 <- lm(gktmathss ~ treat + factor(gkschid),data=s) 42 | summary(ate.maths2)$coef[2,] 43 | 44 | 45 | # (d) 46 | s$missing <- ifelse( is.na(s$g1classtype) | is.na(s$g1treadss) | is.na(s$g1tmathss) ,1,0) 47 | sum(s$missing) / length(s$missing) 48 | 49 | s$missing <- ifelse( (is.na(s$g1classtype)) | (is.na(s$g1treadss) & is.na(s$g1tmathss)) ,1,0) 50 | sum(s$missing) / length(s$missing) 51 | 52 | 53 | 54 | # (e) 55 | s$treat2 <- ifelse(s$g1classtype=="SMALL CLASS",1,0) 56 | 57 | ate.reading.p2 <- lm(g1treadss ~ treat2 + factor(gkschid),data=s) 58 | summary(ate.reading.p2)$coef[2,] 59 | 60 | ate.maths.p2 <- lm(g1tmathss ~ treat2 + factor(gkschid),data=s) 61 | summary(ate.maths.p2)$coef[2,] 62 | 63 | 64 | 65 | # (f) 66 | length(s$g1classtype[s$g1classtype=="SMALL CLASS" & s$gkclasstype=="REGULAR CLASS" & 67 | !is.na(s$g1classtype)]) / 68 | length(s$gkclasstype[s$gkclasstype=="REGULAR CLASS"]) 69 | 70 | length(s$g1classtype[s$g1classtype=="REGULAR CLASS" & s$gkclasstype=="SMALL CLASS" & 71 | !is.na(s$g1classtype)]) / 72 | length(s$gkclasstype[s$gkclasstype=="SMALL CLASS"]) 73 | 74 | 75 | # (g) 76 | 77 | # Upper bound 78 | # start by creating a new dataset with new treatment variable, filling in missing values 79 | s.upper <- s 80 | s.upper$treat3 <- ifelse(is.na(s.upper$treat2),s.upper$treat,s.upper$treat2) 81 | 82 | # assign max score to treated units, min score to control units 83 | for(i in 1:length(s.upper$treat3)){ 84 | if(is.na(s.upper$g1treadss[i]) & s.upper$treat3[i]==0){ 85 | s.upper$g1treadss[i] <- min(na.omit(s$g1treadss)) 86 | s.upper$g1tmathss[i] <- min(na.omit(s$g1tmathss)) 87 | } 88 | 89 | else if(is.na(s.upper$g1treadss[i]) & s.upper$treat3[i]==1){ 90 | s.upper$g1treadss[i] <- max(na.omit(s$g1treadss)) 91 | s.upper$g1tmathss[i] <- max(na.omit(s$g1tmathss)) 92 | } 93 | } 94 | 95 | 96 | ate.reading.upper <- lm(g1treadss ~ treat3 + factor(gkschid),data=s.upper) 97 | summary(ate.reading.upper)$coef[2,] 98 | 99 | ate.maths.upper <- lm(g1tmathss ~ treat3 + factor(gkschid),data=s.upper) 100 | summary(ate.maths.upper)$coef[2,] 101 | 102 | 103 | # Lower bound 104 | # start by creating a new dataset with new treatment variable, filling in missing values 105 | s.lower <- s 106 | s.lower$treat3 <- ifelse(is.na(s.lower$treat2),s.lower$treat,s.lower$treat2) 107 | 108 | # assign min score to treated units, max score to control units 109 | for(i in 1:length(s.lower$treat3)){ 110 | if(is.na(s.lower$g1treadss[i]) & s.lower$treat3[i]==0){ 111 | s.lower$g1treadss[i] <- max(na.omit(s$g1treadss)) 112 | s.lower$g1tmathss[i] <- max(na.omit(s$g1tmathss)) 113 | } 114 | 115 | else if(is.na(s.lower$g1treadss[i]) & s.lower$treat3[i]==1){ 116 | s.lower$g1treadss[i] <- min(na.omit(s$g1treadss)) 117 | s.lower$g1tmathss[i] <- min(na.omit(s$g1tmathss)) 118 | } 119 | } 120 | 121 | ate.reading.lower <- lm(g1treadss ~ treat3 + factor(gkschid),data=s.lower) 122 | summary(ate.reading.lower)$coef[2,] 123 | 124 | ate.maths.lower <- lm(g1tmathss ~ treat3 + factor(gkschid),data=s.lower) 125 | summary(ate.maths.lower)$coef[2,] 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment 4.R: -------------------------------------------------------------------------------- 1 | ## Question 1 ## 2 | 3 | library("ri") 4 | load("t4data.Rda") 5 | 6 | # a): ATE, report p-value 7 | reg1 <- lm(Y~tr,data=a) 8 | summary(reg1) 9 | ate <- reg1$coef[2] 10 | 11 | # b) 12 | perms <- genperms(a$tr) 13 | 14 | # c) 15 | ates <- c() 16 | for(i in 1:ncol(perms)){ 17 | ates[i] <- mean(a$Y[perms[,i]==1]) - mean(a$Y[perms[,i]==0]) 18 | } 19 | 20 | # d) calculate exact p-value: two-tailed 21 | (length(ates[ates<=ate]) + length(ates[ates>=-ate])) / ncol(perms) 22 | 23 | # e) histogram 24 | plot(density(ates), 25 | xlab="Average Treatment Effects", 26 | main="Distribution of ATEs Under the\n Sharp Null Hypothesis") 27 | abline(v=ate,col="red",lwd=2) 28 | abline(v=quantile(ates,0.025),col="blue",lty=2) 29 | abline(v=quantile(ates,0.975),col="blue",lty=2) 30 | legend("topright",c("ATE","Critical\n Values"),lty=c(1,2),col=c("red","blue"),ncol=1) 31 | 32 | 33 | # f) using software 34 | Y_null <- genouts(a$Y,a$tr,ate=0) 35 | distout <- gendist(Y_null,perms) 36 | dispdist(distout,ate) 37 | 38 | # g) 39 | reg2 <- lm(Y~tr + factor(block),data=a) 40 | summary(reg2) 41 | ate <- reg2$coef[2] 42 | 43 | # h) how many perms now? 44 | perms <- genperms(a$tr,blockvar=a$block) 45 | 46 | # i) using software: what do you notice about sampling dist compared to before 47 | Y_null <- genouts(a$Y,a$tr,ate=0) 48 | distout <- gendist(Y_null,perms) 49 | dispdist(distout,ate) 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment 5.R: -------------------------------------------------------------------------------- 1 | library(MatchIt) 2 | library(Matching) 3 | 4 | ldata <- MatchIt::lalonde 5 | 6 | 7 | # (a) 8 | m1 <- lm(re78 ~ treat +hispan + educ + married, data = ldata) 9 | summary(m1) 10 | 11 | # (b) 12 | matching.vars1 <- cbind(ldata$hispan,ldata$educ, ldata$married) 13 | m1 <- Match(Y=ldata$re78, Tr=ldata$treat, X=matching.vars1, exact=TRUE) 14 | summary.Match(m1) 15 | 16 | # (c) 17 | mbal1 <- MatchBalance(treat ~ hispan + educ + married, match.out=m1, data=ldata) 18 | 19 | # (d) 20 | matching.vars2 <- cbind(ldata$hispan,ldata$educ, ldata$married, ldata$re74, ldata$re75) 21 | m2 <- Match(Y=ldata$re78, Tr=ldata$treat, X=matching.vars2,Weight=2) 22 | summary.Match(m2) 23 | mbal2 <- MatchBalance(treat ~ hispan + educ + married + re74 + re75, match.out=m2, data=ldata) 24 | 25 | 26 | # (e) 27 | propscores.reg <- glm(treat~age+educ+black+hispan+married+nodegree+re74+re75, family=binomial, data=ldata) 28 | propscores <- fitted.values(propscores.reg) 29 | ldata <- cbind(ldata,propscores) 30 | 31 | # (f) 32 | m3 <- Match(Y=ldata$re78, Tr=ldata$treat, X=propscores,Weight=2) 33 | summary.Match(m3) 34 | mbal3 <- MatchBalance(treat ~ age+educ+black+hispan+married+nodegree+re74+re75, match.out=m3, data=ldata) 35 | 36 | 37 | # (g) 38 | m4 <- Match(Y=ldata$re78, Tr=ldata$treat, X=propscores,Weight=2,ties=F) 39 | summary.Match(m4) 40 | 41 | ldata.tr <- ldata[m4$index.treated,] 42 | ldata.con <- ldata[m4$index.control,] 43 | ldata.reg <- rbind(ldata.tr,ldata.con) 44 | 45 | summary(lm(re78 ~ treat + propscores,data=ldata.reg)) 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment 6.R: -------------------------------------------------------------------------------- 1 | # Question 1 2 | 3 | load("guangreen.Rda") 4 | 5 | # a) 6 | # assigned to control, contacted 7 | length(g$contact[g$contact==1&g$treat2==0]) 8 | # assigned to treatment, not contacted 9 | length(g$contact[g$contact==0&g$treat2==1]) 10 | 11 | # c) 12 | prop.c <- sum(g$contact)/sum(g$treat2) 13 | 14 | # d) 15 | itt <- mean(g$turnout[g$treat2==1]) - mean(g$turnout[g$treat2==0]) 16 | 17 | # e) 18 | cace <- itt/prop.c 19 | 20 | 21 | ############################################################# 22 | 23 | ### QUESTION 2: HAJJ PILGRIMAGE ### 24 | 25 | load("hajjdata.Rda") 26 | 27 | # (a) 28 | # assigned to control, went on hajj 29 | length(h$hajj2006[h$success==0&h$hajj2006==1])/length(h$hajj2006[h$success==0]) 30 | # assigned to treatment, didn't go on hajj 31 | length(h$hajj2006[h$success==1&h$hajj2006==0])/length(h$hajj2006[h$success==1]) 32 | 33 | # (c) 34 | itt <- mean(h$moderacy[h$success==1]) - mean(h$moderacy[h$success==0]) 35 | 36 | prop.c <- sum(h$hajj2006[h$success==1])/length(h$hajj2006[h$success==1]) - 37 | sum(h$hajj2006[h$success==0])/length(h$hajj2006[h$success==0]) 38 | 39 | cace <- itt/prop.c 40 | 41 | # (d) 42 | summary(lm(h$hajj2006 ~ h$success)) 43 | 44 | # (e) 45 | library(AER) 46 | summary(ivreg(moderacy ~ hajj2006 | success,data=h)) 47 | 48 | # (f) 49 | summary(ivreg(moderacy ~ hajj2006+age+literate+urban | success+age+literate+urban,data=h)) 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment 7.R: -------------------------------------------------------------------------------- 1 | load("Stokes.Rda") 2 | library(lmtest) 3 | library(AER) 4 | 5 | # a) 6 | summary(lm(avg_pwr_log ~ factor(ed_id) + longitude + latitude + mindistlake + mindistlake_sq,data=s)) 7 | 8 | # b) 9 | summary(lm(prop_3km ~ avg_pwr_log, data=s)) 10 | 11 | # d) 12 | summary(lm(prop_3km ~ avg_pwr_log + factor(ed_id) + longitude + latitude + mindistlake + mindistlake_sq , data=s)) 13 | 14 | # e) 15 | mod1 <- lm(prop_3km ~ longitude + latitude + mindistlake + mindistlake_sq + as.factor(ed_id), data=s) # Run one model without the instrument. 16 | mod2 <- lm(prop_3km ~ avg_pwr_log + longitude + latitude + mindistlake + mindistlake_sq + as.factor(ed_id), data=s) # Run a second model with the instrument. 17 | waldtest(mod2, mod1) #Compare the two using a wald test 18 | 19 | # f) 20 | summary(ivreg(chng_lib ~ prop_3km + mindistlake + mindistlake_sq + longitude + latitude + as.factor(ed_id) 21 | | avg_pwr_log + mindistlake + mindistlake_sq + longitude + latitude + as.factor(ed_id), data = s)) 22 | 23 | # g) 24 | first.stage <- lm(prop_3km ~ avg_pwr_log + factor(ed_id) + longitude + latitude + mindistlake + mindistlake_sq , data=s) 25 | s$fitted.first <- fitted.values(first.stage) 26 | 27 | summary(lm(chng_lib ~ fitted.first + factor(ed_id) + longitude + latitude + mindistlake + mindistlake_sq , data=s)) 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment 8.R: -------------------------------------------------------------------------------- 1 | library(foreign) 2 | library(rdd) 3 | 4 | m <- read.csv("islamic.csv") 5 | 6 | # a 7 | m$islamicwin<-ifelse(m$iwm94>=0,1,0) 8 | 9 | # b 10 | mean(m$hischshr1520f[m$islamicwin==1],na.rm=T) - 11 | mean(m$hischshr1520f[m$islamicwin==0],na.rm=T) 12 | 13 | # c 14 | band <- IKbandwidth(m$iwm94, m$hischshr1520f) 15 | 16 | # d 17 | rdd_est <- m[m$iwm94-band,] 18 | 19 | # e 20 | summary(lm(hischshr1520f~iwm94 + islamicwin, data=rdd_est)) 21 | 22 | # f 23 | rdest <- RDestimate(hischshr1520f~iwm94,bw=band, data=m) 24 | summary(rdest) 25 | 26 | # g 27 | plot(rdest, range=c(-0.6,0.6)) 28 | abline(v=0) 29 | 30 | # h 31 | summary(RDestimate(hischshr1520f~iwm94,bw=band,cutpoint=-0.1,data=m)) 32 | summary(RDestimate(hischshr1520f~iwm94,bw=band,cutpoint=-0.05,data=m)) 33 | summary(RDestimate(hischshr1520f~iwm94,bw=band,cutpoint= 0.05,data=m)) 34 | summary(RDestimate(hischshr1520f~iwm94,bw=band,cutpoint= 0.1,data=m)) 35 | 36 | 37 | # i 38 | summary(RDestimate(sexr~iwm94,bw=band, data=m)) 39 | summary(RDestimate(lpop1994~iwm94,bw=band, data=m)) 40 | summary(RDestimate(lareapre~iwm94,bw=band, data=m)) 41 | 42 | # j 43 | DCdensity(m$iwm94,verbose=T) 44 | abline(v=0) 45 | 46 | # k 47 | rdests=rdci.up=rdci.down <- c() 48 | thresholds <- seq(from=0.05,to=0.6,by=0.005) 49 | 50 | for(i in 1:length(thresholds)){ 51 | rdest <- RDestimate(hischshr1520f~iwm94,bw=thresholds[i], data=m) 52 | rdests[i] <- rdest$est[1] 53 | rdci.up[i] <- rdests[i] + 1.96*rdest$se[1] 54 | rdci.down[i] <- rdests[i] -1.96*rdest$se[1] 55 | } 56 | 57 | plot(rdests, 58 | type="l", 59 | lwd=2, 60 | ylim=c(-0.1,0.1), 61 | xaxt="n", 62 | xlab="Threshold", 63 | ylab="Estimate") 64 | axis(1, 65 | at=c(1,31,51,71,91,111), 66 | labels=c(0.05,0.2,0.3,0.4,0.5,0.6)) 67 | abline(h=0) 68 | lines(rdci.up, 69 | lty=3) 70 | lines(rdci.down, 71 | lty=3) 72 | legend("topright", 73 | c("RD Estimate","95% Confidence Interval"), 74 | lty=c(1,3)) 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment 9.R: -------------------------------------------------------------------------------- 1 | library(foreign) 2 | library(lmtest) 3 | library(multiwayvcov) 4 | library(plm) 5 | 6 | ##### Q1: Malesky ####### 7 | load("malesky.Rda") 8 | 9 | # (a) create the time dummy and the interaction term for diff in diff 10 | m3 <- m[m$year>2006,] 11 | m3$time <- ifelse(m3$year==2010,1,0) 12 | 13 | m3$time_treat <- m3$time*m3$treatment 14 | 15 | # (b) do diff-in-diff, no covariates 16 | summary(lm(infra ~ time + treatment + time_treat,data=m3)) 17 | 18 | # (c) diff-in-diff, covariates 19 | model1 <- lm(infra ~ time + treatment + time_treat + lnpopden,data=m3) 20 | summary(model1) 21 | 22 | # (d) cluster the standard error at the district level 23 | coeftest(model1, cluster.vcov(model1,m3$district)) 24 | 25 | # (f) parallel trends pic 26 | 27 | # means, treated 28 | means.t <- c(mean(m$infra[m$year==2006&m$treatment==1]), 29 | mean(m$infra[m$year==2008&m$treatment==1]), 30 | mean(m$infra[m$year==2010&m$treatment==1])) 31 | 32 | #means,control 33 | means.c <- c(mean(m$infra[m$year==2006&m$treatment==0]), 34 | mean(m$infra[m$year==2008&m$treatment==0]), 35 | mean(m$infra[m$year==2010&m$treatment==0])) 36 | 37 | # plot 38 | plot(means.t, 39 | ylim=c(2.6,3.6), 40 | type="o", 41 | pch=16, 42 | col="red", 43 | xaxt="n", 44 | xlab="Year", 45 | ylab="Infrastructure Index") 46 | lines(means.c,type="o",pch=15,col="blue") 47 | axis(1,at=c(1,2,3),lab=c(2006,2008,2010)) 48 | legend("topleft", 49 | c("Treated","Control"), 50 | col=c("red","blue"), 51 | pch=c(16,15), 52 | lty=c(1,1)) 53 | 54 | # (g) placebo diff-in-diff [can't cluster because district IDs aren't provided pre the shift] 55 | m4 <- m[m$year<2010,] 56 | m4$time <- ifelse(m4$year==2008,1,0) 57 | m4$time_treat <- m4$time*m4$treatment 58 | 59 | summary(lm(infra ~ time + treatment + time_treat + lnpopden ,data=m4)) 60 | 61 | 62 | 63 | ############################### 64 | # Fixed effects Question 2 65 | 66 | load("Stokes_fe.Rda") 67 | 68 | # b) 69 | mod_fe1 <- plm(perc_lib ~ op + factor(master_id)*year, data = s, 70 | index = c("master_id", "year"),effect = "twoways") 71 | coeftest(mod_fe1, vcov=vcovHC(mod_fe1, cluster="group", type="HC1")) 72 | 73 | # probably better to include all covariates (all vary over time) 74 | mod_fe2 <- plm(perc_lib ~ op + p_uni_degree + log_pop_denc + unemploy_rate + log_median_inc + p_immigrant, 75 | data = s, index = c("master_id", "year"), effect = "twoways") 76 | coeftest(mod_fe2, vcov=vcovHC(mod_fe2, cluster="group", type="HC1")) 77 | 78 | # d) 79 | # means, treated 80 | means.t <- c(mean(s$perc_lib[s$year==2003&s$treat_o==1]), 81 | mean(s$perc_lib[s$year==2007&s$treat_o==1]), 82 | mean(s$perc_lib[s$year==2011&s$treat_o==1])) 83 | 84 | #means,control 85 | means.c <- c(mean(s$perc_lib[s$year==2003&s$treat_o==0]), 86 | mean(s$perc_lib[s$year==2007&s$treat_o==0]), 87 | mean(s$perc_lib[s$year==2011&s$treat_o==0])) 88 | 89 | # plot 90 | plot(means.t, 91 | ylim=c(0.2,0.6), 92 | type="o", 93 | pch=16, 94 | col="red", 95 | xaxt="n", 96 | xlab="Year", 97 | ylab="Incumbent Vote Share") 98 | lines(means.c,type="o",pch=15,col="blue") 99 | axis(1,at=c(1,2,3),lab=c(2003,2007,2011)) 100 | legend("topright", 101 | c("Treated","Control"), 102 | col=c("red","blue"), 103 | pch=c(16,15), 104 | lty=c(1,1)) 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /Weekly R Assignments - Code/Code - Weekly Assignment x10.R: -------------------------------------------------------------------------------- 1 | load("africa.Rda") 2 | library(Synth) 3 | 4 | # a) prepare data for synth 5 | 6 | mali.data <- dataprep(a, 7 | predictors=c(#"lngdpmad", 8 | "lnpop", 9 | "ki", 10 | "openk", 11 | "civwar", 12 | "civwarend", 13 | "pwt_xrate", 14 | "eximdiff", 15 | "wbank", 16 | "imfadj"), 17 | dependent="lngdpmad", 18 | unit.variable="wbcode2", 19 | unit.names.variable="Country", 20 | time.variable="year", 21 | treatment.identifier="Mali", 22 | controls.identifier=c(unique(a$Country[a$Country!="Mali"])), 23 | time.predictors.prior=c(1975:1990), 24 | time.optimize.ssr=c(1975:1991), 25 | time.plot=c(1975:2008)) 26 | 27 | 28 | 29 | # b) estimate 30 | set.seed(123) 31 | synth.mali <- synth(mali.data) 32 | 33 | 34 | # c) plot treatment vs. synthetic control 35 | pdf(file="ps8_1.pdf") 36 | path.plot(synth.res=synth.mali, dataprep.res=mali.data, 37 | tr.intake=1991,Ylab="Log GDP per capita",Xlab="") 38 | dev.off() 39 | 40 | # d) describe which units are included in the control 41 | mali.weights <- synth.mali$solution.w 42 | 43 | # e) describe which variables are included in the synthetic control estimate 44 | mali.vars <- synth.mali$solution.v 45 | 46 | # f) plot the treatment effect (requires matrix algebra to get the synth fitted values) 47 | synthetic.mali <- mali.data$Y0plot %*% mali.weights 48 | actual.mali <- a$lngdpmad[a$Country=="Mali"&a$year>1974] 49 | 50 | treatment.effect <- actual.mali - synthetic.mali 51 | 52 | plot(treatment.effect, 53 | type="l", 54 | lwd=2, 55 | ylim=c(-0.5,1.2), 56 | xlab="", 57 | ylab="Log GDP per Capita", 58 | xaxt="n") 59 | axis(1,at=c(1,8,15,22,29),labels=c(1975,1983,1990,1997,2004)) 60 | abline(v=16,lty=3) 61 | abline(h=0) 62 | 63 | # g) do the synth again but for a control. 64 | a.angola <- subset(a,a$Country!="Mali") 65 | angola.data <- dataprep(a.angola, 66 | predictors=c("lngdpmad", 67 | "lnpop", 68 | "ki", 69 | "openk", 70 | "civwar", 71 | "civwarend", 72 | "pwt_xrate", 73 | "eximdiff", 74 | "wbank", 75 | "imfadj"), 76 | dependent="lngdpmad", 77 | unit.variable="wbcode2", 78 | unit.names.variable="Country", 79 | time.variable="year", 80 | treatment.identifier="Angola", 81 | controls.identifier=c(unique(a.angola$Country[a.angola$Country!="Angola"])), 82 | time.predictors.prior=c(1975:1990), 83 | time.optimize.ssr=c(1975:1991), 84 | time.plot=c(1975:2008)) 85 | 86 | synth.angola <- synth(angola.data) 87 | angola.weights <- synth.angola$solution.w 88 | 89 | synthetic.angola <- angola.data$Y0plot %*% angola.weights 90 | actual.angola <- a$lngdpmad[a$Country=="Angola" & a$year>1974] 91 | treatment.effect.angola <- actual.angola - synthetic.angola 92 | 93 | plot(treatment.effect, 94 | type="l", 95 | lwd=2, 96 | ylim=c(-0.5,1.2), 97 | xlab="", 98 | ylab="Log GDP per Capita", 99 | xaxt="n") 100 | axis(1,at=c(1,8,15,22,29),labels=c(1975,1983,1990,1997,2004)) 101 | abline(v=16,lty=3) 102 | abline(h=0) 103 | lines(treatment.effect.angola,lty=2,lwd=1) 104 | legend("topright",c("Mali","Placebo"),lty=c(1,2)) 105 | 106 | 107 | 108 | # h) use a for loop combined with the unique() command to do it for all of them 109 | 110 | plot(treatment.effect, 111 | type="l", 112 | lwd=2, 113 | ylim=c(-0.5,1.2), 114 | xlab="", 115 | ylab="Log GDP per Capita", 116 | xaxt="n") 117 | axis(1,at=c(1,8,15,22,29),labels=c(1975,1983,1990,1997,2004)) 118 | abline(v=16,lty=3) 119 | abline(h=0) 120 | legend("topright",c("Mali","Placebo"),lty=c(1,2)) 121 | 122 | 123 | a.controls <- subset(a,a$Country!="Mali") 124 | for(i in 1:length(unique(a.controls$Country))){ 125 | my.country <- unique(a.controls$Country)[i] 126 | 127 | controls.data <- dataprep(a.controls, 128 | predictors=c("lngdpmad", 129 | "lnpop", 130 | "ki", 131 | "openk", 132 | "civwar", 133 | "civwarend", 134 | "pwt_xrate", 135 | "eximdiff", 136 | "wbank", 137 | "imfadj"), 138 | dependent="lngdpmad", 139 | unit.variable="wbcode2", 140 | unit.names.variable="Country", 141 | time.variable="year", 142 | treatment.identifier=my.country, 143 | controls.identifier=c(unique(a.controls$Country[a.controls$Country!=my.country])), 144 | time.predictors.prior=c(1975:1990), 145 | time.optimize.ssr=c(1975:1991), 146 | time.plot=c(1975:2008)) 147 | 148 | synth.control <- synth(controls.data) 149 | control.weights <- synth.control$solution.w 150 | 151 | synthetic.control <- controls.data$Y0plot %*% control.weights 152 | actual.control <- a$lngdpmad[a$Country==my.country & a$year>1974] 153 | treatment.effect.control <- actual.control - synthetic.control 154 | 155 | lines(treatment.effect.control,lty=2,lwd=1) 156 | } 157 | 158 | 159 | -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/Stokes.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/Stokes.Rda -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/Stokes_fe.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/Stokes_fe.Rda -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/africa.RDa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/africa.RDa -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/benin.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/benin.Rda -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/experiment.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/experiment.Rda -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/fishdata.csv: -------------------------------------------------------------------------------- 1 | COUNTRY,FHREVERS,GDP90LGN,ETHLING,GRW7598P,BRITCOL,POSTCOM,OPEC,MUSLIM Alb,4.099999905,2.925312042,0.25999999,-0.800000012,0,1,0,1 Alg,2.150000095,3.214313984,0.310000002,0.200000003,0,0,1,1 Arg,5.650000095,3.762078047,0.209999993,0.600000024,0,0,0,0 Arm,3.949999809,3.187802553,0.159999996,-6.599999905,0,1,0,0 Austria,7,4.43554163,0.140000001,2.200000048,0,0,0,0 Austrl,7,4.25582695,0.129999995,1.899999976,1,0,0,0 Aze,2.599999905,3.028164387,0.370000005,-9.800000191,0,1,0,1 Bahr,1.850000024,3.93201685,0.529999971,-1.399999976,0,0,0,1 Bang,4.949999809,2.437750578,0.310000002,2.400000095,1,0,0,1 Bela,2.900000095,3.441066504,0.360000014,-1.299999952,0,1,0,0 Belg,6.75,4.410676003,0.649999976,1.899999976,0,0,0,0 Ben,6,2.537819147,0.899999976,0.699999988,0,0,0,0 Bhut,1.149999976,2.587710857,0.819999993,4.300000191,0,0,0,0 Bol,5.650000095,2.922206163,0.680000007,-0.200000003,0,0,0,0 Bot,6,3.494710922,0.439999998,5.199999809,1,0,0,0 Bra,4.900000095,3.610447168,0.029999999,1.200000048,0,0,0,0 Bul,5.650000095,3.234517336,0.219999999,0.200000003,0,1,0,0 Burk,3.449999809,2.352182627,0.75999999,1.200000048,0,0,0,1 Buru,1.550000191,2.313867331,0,-0.400000006,0,0,0,0 Camb,2.25,2.380211353,0.310000002,2,0,0,0,0 Camr,2.050000191,2.883093357,0.970000029,0.200000003,0,0,0,0 Can,7,4.282395363,0.550000012,1.5,1,0,0,0 CAR,4,2.559906721,0.959999979,-1.200000048,0,0,0,0 Chad,2.550000191,2.357934952,0.949999988,-0.400000006,0,0,0,1 Chile,6,3.475235224,0.059999999,4.199999809,0,0,0,0 China,1.150000095,2.54282546,0.479999989,7.5,0,0,0,0 Col,4.400000095,3.326130867,0.029999999,1.700000048,0,0,0,0 Com,3.849999905,2.712649584,0.01,-1.200000048,0,0,0,1 Cong-Z,1.099999905,2.392696857,0.920000017,-4.800000191,0,0,0,0 Cong,3.449999809,2.969881535,0.610000014,0.600000024,0,0,0,0 Cotd'lv,2.75,2.898176432,0.910000026,-1,0,0,0,1 CR,6.599999905,3.380753756,0.039999999,1,0,0,0,0 Cro,4.199999809,3.734959841,0.07,-1.399999976,0,1,0,0 Cyp,7,4.017241955,0.370000005,5.699999809,1,0,0,0 Cze,6.5,3.721810579,0.059999999,2.200000048,0,1,0,0 Den,7,4.493360519,0.050000001,2.099999905,0,0,0,0 Dji,2.5,2.954242468,0.579999983,-4.599999905,0,0,0,1 DR,5.199999809,3.135450602,0.050000001,1.899999976,0,0,0,0 Ecu,5.599999905,3.168792009,0.25999999,0.800000012,0,0,0,0 Egy,2.25,2.987219334,0.460000008,3.5,0,0,0,1 ElSal,5.150000095,3.139249325,0,-0.200000003,0,0,0,0 Erit,2.630000114,2.217483997,0.689999998,1.799999952,0,0,0,1 Est,6,3.651956081,0.479999989,-0.100000001,0,1,0,0 Eth,3.099999905,2,0.839999974,-0.400000006,0,0,0,1 Fiji,4.349999905,3.372175217,0.600000024,0.600000024,1,0,0,0 Fin,7,4.414254665,0.140000001,2,0,0,0,0 Fra,6.5,4.40864706,0.239999995,1.799999952,0,0,0,0 Gab,3.650000095,3.647578478,0.529999971,-1.5,0,0,0,0 Gam,3.050000191,2.572871685,0.730000019,0,1,0,0,1 Geo,3.699999809,3.325310469,0.569999993,-4,0,1,0,0 Ger,6.5,4.356408119,0.180000007,1.200000048,0,0,0,0 Gha,4.099999905,2.546542645,0.790000021,-0.100000001,1,0,0,0 Gre,6.099999905,4.03080225,0.140000001,1.600000024,0,0,0,0 Guat,4.049999714,3.132899761,0.600000024,0.5,0,0,0,0 Guin-B,3.699999809,2.348304749,0.850000024,-1.100000024,0,0,0,0 Guin,2.5,2.725911617,0.75,1.399999976,0,0,0,1 Guy,5.650000095,2.743509769,0.07,-0.200000003,1,0,0,0 Hai,2.449999809,2.682145119,0,-1.299999952,0,0,0,0 Hon,5.199999809,2.833784342,0.050000001,0.699999988,0,0,0,0 Hun,6.400000095,3.686367989,0.140000001,1.399999976,0,1,0,0 India,4.75,2.519828081,0.930000007,3,1,0,0,0 Indo,3.150000095,2.890979528,0.829999983,4.099999905,0,0,1,1 Iran,1.699999809,3.023663998,0.75999999,-1,0,0,1,1 Iraq,1,3.387389898,0.649999976,-3.5,0,0,1,1 Ire,7,4.143233299,0.170000002,4.400000095,0,0,0,0 Isr,6.050000191,4.132452011,0.649999976,1.799999952,0,0,0,0 Ita,6.5,4.25866127,0.589999974,2.200000048,0,0,0,0 Jam,5.75,3.217746973,0.01,-0.699999988,1,0,0,0 Japan,6.429999828,4.58785677,0.029999999,2.599999905,0,0,0,0 Jor,4.049999714,3.157154322,0.479999989,1.799999952,0,0,0,1 Kaz,3.150000095,3.316599369,0.699999988,-4.699999809,0,1,0,1 Ken,2.25,2.550228357,0.899999976,0.5,1,0,0,0 Kuw,3.099999905,4.100370407,0.540000021,-1.299999952,0,0,1,1 Kyr,4.099999905,3.193681002,0.670000017,-3.400000095,0,1,0,1 Laos,1.5,2.506505013,0.560000002,4.300000191,0,0,0,0 Lat,5.900000095,3.568553686,0.600000024,-0.800000012,0,1,0,0 Leb,2.650000095,3.235780954,0.140000001,2,0,0,0,1 Les,3.849999905,2.56820178,0.25999999,3.5,1,0,0,0 Liby,1,3.809761763,0.349999994,-3.599999905,0,0,1,1 Lith,6.199999809,3.503926754,0.340000004,-1.5,0,1,0,0 Mac,4.670000076,2.913813829,0.49000001,0,0,1,0,0 Mad,4.799999714,2.440909147,0.5,-1.799999952,0,0,0,0 Malaw,4.299999714,2.181843519,0.699999988,0.200000003,1,0,0,0 Malay,3.349999905,3.500236511,0.75,3.900000095,1,0,0,1 Mali,5.099999905,2.396199465,0.860000014,0,0,0,0,1 Mauritan,1.900000095,2.641474009,0.189999998,-0.600000024,0,0,0,1 Mauritius,6.449999809,3.470557451,0.600000024,4.300000191,1,0,0,0 Mex,4.400000095,3.607025862,0.129999995,1.200000048,0,0,0,0 Mol,4.150000095,3.249443054,0.589999974,-4.699999809,0,1,0,0 Mon,5.5,2.697229385,0.300000012,-0.100000001,0,1,0,0 Mor,3.099999905,3.117271185,0.469999999,1.600000024,0,0,0,1 Moz,3.900000095,2.158362389,0.920000017,0.699999988,0,0,0,0 Mya,1,2.863322973,0.639999986,1.5,1,0,0,0 Nam,5.549999714,3.289588928,0.839999974,-0.600000024,0,0,0,0 Nep,4.699999809,2.260071278,0.689999998,1.600000024,0,0,0,0 Neth,7,4.380373955,0.200000003,1.799999952,0,0,0,0 Nic,4.599999905,2.662757874,0.079999998,-3.400000095,0,0,0,0 Niger,3.150000095,2.371067762,0.639999986,-1.399999976,0,0,0,1 Nigeria,2.599999905,2.411619663,0.879999995,-0.699999988,1,0,1,1 Nor,7,4.45999527,0.079999998,2.900000095,0,0,0,0 NZ,7,4.176843166,0.100000001,0.699999988,1,0,0,0 Oman,2.099999905,3.746711969,0.680000007,2.400000095,0,0,0,1 Pak,3.400000095,2.651278019,0.829999983,2.700000048,1,0,0,1 Pan,5.650000095,3.401917219,0.230000004,1,0,0,0,0 PapNG,5.25,2.948412895,0.99000001,0.200000003,0,0,0,0 Par,4.650000095,3.259115934,0.330000013,1.399999976,0,0,0,0 Peru,3.599999905,3.303627968,0.349999994,-0.400000006,0,0,0,0 Phil,5.150000095,3.026941538,0.850000024,0.5,0,0,0,0 Pol,6.300000191,3.462398052,0.119999997,1.600000024,0,1,0,0 Por,7,3.986592531,0.02,2.900000095,0,0,0,0 Rom,4.949999809,3.197556257,0.200000003,-0.100000001,0,1,0,0 Rus,4.25,3.564429283,0.270000011,-0.800000012,0,1,0,0 Rwa,1.699999809,2.465382814,0,-0.100000001,0,0,0,0 SAf,5.5,3.61415863,0.870000005,-0.699999988,0,0,0,0 SArab,1.050000191,3.851258278,0.560000002,-1.700000048,0,0,1,1 Sen,4.049999714,2.757395983,0.769999981,-0.200000003,0,0,0,1 Sing,2.799999952,4.300312996,0.74000001,5.699999809,1,0,0,0 SKor,5.900000095,3.901294708,0,6,0,0,0,0 SLeo,2.5,2.445604086,0.819999993,-3.200000048,1,0,0,1 Slovak,5.559999943,3.58263135,0.25,0.600000024,0,1,0,0 Sloven,6.349999905,3.984932184,0.170000002,1.200000048,0,1,0,0 Spa,6.5,4.129722118,0.439999998,1.899999976,0,0,0,0 SriLan,3.949999809,2.770852089,0.310000002,3.299999952,1,0,0,0 Sud,1,2.296665192,0.560000002,1,1,0,0,1 Swaz,2.550000191,3.160168409,0.230000004,1.200000048,1,0,0,0 Swe,7,4.421554565,0.370000005,1.200000048,0,0,0,0 Swit,7,4.662294865,0.529999971,0.899999976,0,0,0,0 Syr,1,2.980457783,0.5,1.299999952,0,0,0,1 Taj,1.900000095,2.856124401,0.479999989,-6.699999809,0,1,0,1 Tan,3,2.243037939,0.949999988,0.200000003,1,0,0,0 Thai,4.650000095,3.302330971,0.75,4.900000095,0,0,0,0 Togo,2.550000191,2.574031353,0.889999986,-0.899999976,0,0,0,0 Trin,6.650000095,3.612253904,0.469999999,1.5,1,0,0,0 Tun,2.550000191,3.260786772,0.01,2.200000048,0,0,0,1 Turk,3.75,3.413131952,0.25,2.299999952,0,0,0,1 Turkmn,1.199999809,3.062205791,0.379999995,-7.599999905,0,1,0,1 UAE,2.450000048,4.32199192,0.779999971,-3.5,0,0,1,1 Uga,3.099999905,2.3996737,0.930000007,2.200000048,1,0,0,0 UK,6.5,4.256043911,0.07,1.899999976,0,0,0,0 Ukr,4.449999809,3.296445847,0.479999989,-7.599999905,0,1,0,0 Uru,6.400000095,3.663795233,0.090000004,1.700000048,0,0,0,0 US,7,4.404200554,0.349999994,1.899999976,1,0,0,0 Uz,1.400000095,3.126456022,0.439999998,-2,0,1,0,1 Ven,5,3.52543354,0.02,-0.800000012,0,0,1,0 Vie,1,2.313867331,0.200000003,4.400000095,0,0,0,0 Yem,2.650000095,2.424881697,0.560000002,-0.600000024,0,0,0,1 Zam,4.199999809,2.653212547,0.899999976,-2.200000048,1,0,0,0 Zim,3,2.848804712,0.560000002,0.100000001,1,0,0,0 -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/guangreen.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/guangreen.Rda -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/hajjdata.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/hajjdata.Rda -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/malesky.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/malesky.Rda -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/star.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/star.Rda -------------------------------------------------------------------------------- /Weekly R Assignments - Datasets/t4data.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Datasets/t4data.Rda -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set 1 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set 1 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set 2 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set 2 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set 3 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set 3 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set 4 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set 4 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set 5 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set 5 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set 6 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set 6 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set 7 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set 7 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set 8 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set 8 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set 9 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set 9 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/Problem Set x10 - Solutions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments - Solutions/Problem Set x10 - Solutions.pdf -------------------------------------------------------------------------------- /Weekly R Assignments - Solutions/h: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Weekly R Assignments/Problem Set 1_stats intro.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/Problem Set 1_stats intro.pdf -------------------------------------------------------------------------------- /Weekly R Assignments/Problem Set 2_experiments I.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/Problem Set 2_experiments I.pdf -------------------------------------------------------------------------------- /Weekly R Assignments/Problem Set 3_experiments II.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/Problem Set 3_experiments II.pdf -------------------------------------------------------------------------------- /Weekly R Assignments/Problem Set 4_experiments III.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/Problem Set 4_experiments III.pdf -------------------------------------------------------------------------------- /Weekly R Assignments/Problem Set 5_matching.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/Problem Set 5_matching.pdf -------------------------------------------------------------------------------- /Weekly R Assignments/Problem Set 6_instrumental variables I.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/Problem Set 6_instrumental variables I.pdf -------------------------------------------------------------------------------- /Weekly R Assignments/Problem Set 7_instrumental variables II.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/Problem Set 7_instrumental variables II.pdf -------------------------------------------------------------------------------- /Weekly R Assignments/Problem Set 8_regression discontinuity.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/Problem Set 8_regression discontinuity.pdf -------------------------------------------------------------------------------- /Weekly R Assignments/Problem Set 9_difference in differences.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/Problem Set 9_difference in differences.pdf -------------------------------------------------------------------------------- /Weekly R Assignments/xProblem Set 10_synthetic control.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/verenakunz/Causal-Inference-for-Beginning-Undergraduates/46001166fd2fd6b1e42443556502b23935a5e576/Weekly R Assignments/xProblem Set 10_synthetic control.pdf --------------------------------------------------------------------------------