1 Star 0 Fork 1

titzp/Causal-Inference-Using-Quasi-Experimental-Methods

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
3. Difference-In-Differences 928 Bytes
一键复制 编辑 原始数据 按行查看 历史
# https://towardsdatascience.com/does-minimum-wage-decrease-employment-a-difference-in-differences-approach-cb208ed07327
d <- read.csv(“wage_data.csv”,convert.factors = FALSE)
head(d[, c(“ID”, “nj”, “postperiod”, “emptot”)])
with(d,
(
mean(emptot[nj == 1 & postperiod == 1], na.rm = TRUE) — mean(emptot[nj == 1 & postperiod == 0], na.rm = TRUE)
)-
(mean(emptot[nj == 0 & postperiod == 1], na.rm = TRUE) — mean(emptot[nj == 0 & postperiod == 0], na.rm = TRUE)
)
)
ols <- lm(emptot ~ postperiod * nj, data = d)
coeftest(ols)
#A set of estimators and tests for panel data econometrics
library(plm)
library(lmtest)
d$Dit <- d$nj * d$postperiod
d <- plm.data(d, indexes = c("ID", "postperiod"))
did.reg <- plm(emptot ~ postperiod + Dit, data = d,model = "within")
coeftest(did.reg, vcov=function(x)
#Heteroskedasticity-Consistent Covariance Matrix Estimation
vcovHC(x, cluster="group", type="HC1"))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/titzp/Causal-Inference-Using-Quasi-Experimental-Methods.git
git@gitee.com:titzp/Causal-Inference-Using-Quasi-Experimental-Methods.git
titzp
Causal-Inference-Using-Quasi-Experimental-Methods
Causal-Inference-Using-Quasi-Experimental-Methods
master

搜索帮助