我有一个来自
mediation::mediate
电话的模型摘要,我想将其导出到 LaTeX。考虑这个例子(来自文档)。
# install.packages("mediation")
library("mediation")
set.seed(2014)
data("framing", package = "mediation")
med.fit <- lm(emo ~ treat + age + educ + gender + income, data = framing)
out.fit <- glm(cong_mesg ~ emo + treat + age + educ + gender + income, data = framing, family = binomial("probit"))
med.out <- mediate(med.fit, out.fit, treat = "treat", mediator = "emo", robustSE = TRUE, sims = 100)
我现在想将
summary()
的 med.out
导出到 LaTeX 表。 (重要的是,应包括所有系数!)。
med.out %>% summary()
# Gives the following output:
# Causal Mediation Analysis
# Quasi-Bayesian Confidence Intervals
# Estimate 95% CI Lower 95% CI Upper p-value
# ACME (control) 0.0791 0.0351 0.15 <2e-16 ***
# ACME (treated) 0.0804 0.0367 0.16 <2e-16 ***
# ADE (control) 0.0206 -0.0976 0.12 0.70
# ADE (treated) 0.0218 -0.1053 0.12 0.70
# Total Effect 0.1009 -0.0497 0.23 0.14
# Prop. Mediated (control) 0.6946 -6.3109 3.68 0.14
# Prop. Mediated (treated) 0.7118 -5.7936 3.50 0.14
# ACME (average) 0.0798 0.0359 0.15 <2e-16 ***
# ADE (average) 0.0212 -0.1014 0.12 0.70
# Prop. Mediated (average) 0.7032 -6.0523 3.59 0.14
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# Sample Size Used: 265
# Simulations: 100
我尝试了以下都没有(完全)工作。
med.out %>% modelsummary::modelsummary() # produces output but misses coefficients
med.out %>% texreg::texreg() # produces error
med.out %>% xtable::xtable() # produces error
med.out %>% kableExtra::kable() # produces error
有人知道比从对象中单独获取值更聪明的解决方案吗(例如
med.out$d1
等)?
提前感谢您的指点!