'Regression output tables from the rdrobust package in R
I am relatively new to R and currently trying to make a regression table from my rdrobust results. This is an example of what i am aiming for:

I know that rdrobust is not supported by modelsummary() and that I have to use tidy.rdrobust and glance.rdrobust to make it applicable. So my question is how to specify the parameters in these two commands (tidy,glance) to get the desired output with the modelsummary package?
As shown in the picture I want to have the outcome variables/models as rows and the coefficients (with*),SE,z value and confidence intervals for the three rd methods as columns.
As I said I am relatively new to R and and completely new to programming language in general. Therefore this question is probably not specific enough and provided without any coding trials. Maybe someone can help me anyway.
Thanks a lot!
Solution 1:[1]
Even though it does not satisfy all your requirements, you could leverage the function of modelsummaryfor side-by-side-models: https://vincentarelbundock.github.io/modelsummary/articles/modelsummary.html
library(rdrobust)
library(modelsummary)
tidy.rdrobust <- function(model, ...) {
ret <- data.frame(
term = row.names(model$coef),
std.error = model$se[, 1],
p.value = model$pv[, 1]
)
row.names(ret) <- NULL
ret
}
glance.rdrobust <- function(model, ...) {
ret <- data.frame(
Kernel = model$kernel,
Bandwidth = model$bwselect
)
ret
}
If we implement with dummy data, it will show the following:
x1 <- runif(1000, -1, 1)
x2 <- runif(1000, -1, 1)
y1 <- 5 + 3 * x1 + 2 * (x1 >= 0) + rnorm(1000)
y2 <- 5 + 3 * x2 + 2 * (x2 >= 0) + rnorm(1000)
fit1 <- rdrobust(y1, x1)
fit2 <- rdrobust(y2, x2)
models <- list(fit1, fit2)
modelsummary(models, statistic = "p.value")
| Model 1 | Model 2 | |
|---|---|---|
| Coefficient | X | X |
| Standart Error | X | X |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jonathan Peil |
