-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1. Regression Discontinuity Design
More file actions
30 lines (23 loc) · 1.03 KB
/
1. Regression Discontinuity Design
File metadata and controls
30 lines (23 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# #setwd(“/Users/andy/desktop”)
# original post: https://towardsdatascience.com/the-crown-jewel-of-causal-inference-regression-discontinuity-design-rdd-bad37a68e786
# We are going to use simulated data to examine the treatment effect of an exogenous condition. The research question is whether receiving a scholarship would help students succeed in future professional success.
#To generate a sample data, adn we set the cutoff point = 3.5
GPA <- runif(1000, 0, 4)
future_success <- 10 + 2 * GPA + 10 * (GPA>=3.5) + rnorm(1000)
#install and load the package ‘rddtools’
#install.packages(“rddtools”)
library(rddtools)
data <- rdd_data(future_success, GPA, cutpoint = 3.5)
# plot the dataset
plot(data,col = “red”,
cex = 0.1,
xlab = “GPA”,
ylab = “future_success”)
# estimate the sharp RDD model
rdd_mod <- rdd_reg_lm(rdd_object = data, slope = “same”)
summary(rdd_mod)
# plot the RDD model along with binned observations
plot(rdd_mod,cex = 0.1,
col = “red”,
xlab = “GPA”,
ylab = “future_success”)