stargazer
如果您不使用bayesglm
. 例如,假设我有以下数据:
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)
我可以运行lm
然后为我的 r 降价创建 html(或文本)输出:
lm(data = df1, formula = Y~Treatment+v1+v2) %>%
stargazer::stargazer(type="html", style = "qje")
有没有办法做类似的事情bayesglm
?在这种情况下,pointEstimate
有系数和standardError
标准误
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)