首页 > 解决方案 > rdrobust:为局部多项式估计绘制图形

问题描述

我正在使用 Calonico 和合著者的标准 rdrobust 包来生成 R 中的 RD 估计和绘图。不过,我不清楚是否有一种自动方法来生成带有从局部多项式估计中出现的参数的图。

按照他们在 rdrobust 文档中的示例:

library(rdrobust)
data(rdrobust_RDsenate)
vote <- rdrobust_RDsenate$vote
margin <- rdrobust_RDsenate$margin

全局图

rdplot(y = vote, x = margin, title = "RD Plot - Senate Elections Data",
   x.label = "Vote Share in Election at time t",
   y.label = "Vote Share in Election at time t+1")

局部估计

summary(rdrobust(y = vote, x = margin, all = TRUE))

如何使用估计提供的参数(即 p、h、...)生成图表?

标签: rplotrdd

解决方案


一种更有效的方法是首先运行 rdrobust 并存储结果:

rd1 = rdrobust(y = vote, x = margin)

rdplot1=   rdplot(y = vote, x = margin, 
                  binselect = "es", 
                  scale = 5,
                  kernel = tolower(rd1$kernel),
                  p=rd1$p,
                  h=rd1$bws[1],
                  x.lim = c(-rd1$bws[1],rd1$bws[1]),
                  title = "RD Plot - Senate Elections Data",
                  x.label = "Vote Share in Election at time t",
                  y.label = "Vote Share in Election at time t+1",
                  ci=95)

推荐阅读