stargazer
is a great tool to generate a regression table if you are not using bayesglm
. For example, suppose I have the following data:
library(dplyr)
set.seed(9782)
N<-1000
df1 <- data.frame(v1=sample(c(0,1),N,replace = T),
v2=sample(c(0,1),N,replace = T),
Treatment=sample(c("A", "B", "C"), N, replace = T),
noise=rnorm(N)) %>%
mutate(Y=0.5*v1-0.7*v2+2*I(Treatment=="B")+3*I(Treatment=="C")+noise)
I can run lm
and then create html (or text) output for my r markdown:
lm(data = df1, formula = Y~Treatment+v1+v2) %>%
stargazer::stargazer(type="html", style = "qje")
Is there a way to do something similar for bayesglm
? In this case, pointEstimate
has the coefficients and standardError
the standard errors
library(arm)
fit <- bayesglm(data = df1, formula = Y~Treatment+v1+v2)
posteriorDraws <- coef(sim(fit, n.sims=5000))
pointEstimate <- colMeans(posteriorDraws)
standardError <- apply(posteriorDraws, 2, sd)