Created
September 21, 2020 16:58
-
-
Save vincentarelbundock/5ee12d715d59266beb81ff654d2227d5 to your computer and use it in GitHub Desktop.
rdrobust & modelsummary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rdrobust) | |
library(modelsummary) | |
tidy.rdrobust <- function(object, ...){ | |
ret <- data.frame(term = row.names(object$coef), | |
estimate = object$coef[, 1], | |
std.error = object$se[, 1], | |
statistic = object$z[, 1], | |
p.value = object$pv[, 1], | |
conf.low = object$ci[,1], | |
conf.high = object$ci[, 2]) | |
row.names(ret) <- NULL | |
ret | |
} | |
glance.rdrobust <- function(object, ...){ | |
ret <- data.frame(nobs.left = object$N[1], | |
nobs.right = object$N[2], | |
nobs.effective.left = object$N_h[1], | |
nobs.effective.right = object$N_h[2], | |
cutoff = object$c, | |
order.regression = object$q, | |
order.bias = object$q, | |
kernel = object$kernel, | |
bwselect = object$bwselect) | |
ret | |
} | |
x <- runif(1000, -1, 1) | |
y <- 5 + 3 * x + 2 * (x >= 0) + rnorm(1000) | |
fit <- rdrobust(y, x) | |
modelsummary(fit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much for sharing this script. I think we need to replace
q
withp
on line 22 as: