r - 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、...)生成图表?
解决方案
一种更有效的方法是首先运行 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)
推荐阅读
- xpath - XPATH - 如果元素包含某个类,如何获取文本
- android - 为什么我看不到从 cmd 复制到 android sd 卡的文件?
- azure-ad-b2c - 语言自定义 - 自定义策略 - Azure B2C
- javascript - 创造所有可能性的功能
- python - 使用 Docker 的 Python 脚本沙盒
- javascript - 更新 Observablehq 反应环境中的单元格值
- c++ - 如何在我们重建之前破坏布局Qt c++
- node.js - AWS Lambda 不独立运行
- javascript - HTML Canvas 绘制形状
- wkhtmltopdf - 如何在 php-buildpack (Cloud Foundry) 中运行/安装 wkhtmltopdf