我想使用观星者(具有相同的因变量)将多个单变量模型输出彼此格式化,而我不能让它们不会并排显示。
data(iris)
stargazer(multinom(Species ~ Sepal.Length, data = iris),
multinom(Species ~ Sepal.Width, data = iris),
type = "text", apply.coef = exp, p.auto = FALSE, omit = "Constant")
哪个提供以下输出:
============================================================
Dependent variable:
------------------------------------------
versicolor virginica versicolor virginica
(1) (2) (3) (4)
------------------------------------------------------------
Sepal.Length 123.479*** 941.955***
(0.907) (1.022)
Sepal.Width 0.002*** 0.017***
(0.991) (0.844)
------------------------------------------------------------
Akaike Inf. Crit. 190.068 190.068 260.537 260.537
============================================================
Note: *p<0.1; **p<0.05; ***p<0.01
而不是让“ versicolor”和“ virginica”在不同的模型上重复两次,我只希望它们每个都一次,而不同的模型预测变量和估计相互之间。
有什么办法吗?
starpolishr
可以完成面板格式模型输出的工作,但仅适用于latex
对象,并且仅适用于相等的模型统计信息。
install.packages("remotes")
remotes::install_github("ChandlerLutz/starpolishr")
## -- Regressoin example -- ##
library(stargazer)
data(mtcars)
##First set up models without weight
mod.mtcars.1 <- lm(mpg ~ hp, mtcars)
mod.mtcars.2 <- lm(mpg ~ hp + cyl, mtcars)
star.out.1 <- stargazer(mod.mtcars.1, mod.mtcars.2, keep.stat = "n")
##Second set of models with weight as a regressor
mod.mtcars.3 <- lm(mpg ~ hp + wt, mtcars)
mod.mtcars.4 <- lm(mpg ~ hp + cyl + wt, mtcars)
star.out.2 <- stargazer(mod.mtcars.3, mod.mtcars.4, keep.stat = c("n", "rsq"))
##stargazer panel -- same summary statistics across panels.
star.panel.out <- star_panel(star.out.1, star.out.2,
panel.names = c("Without Weight", "With Weight")
)
print(star.panel.out)
这里您必须删除引号和行号,并且可以编译为.tex输出,如下所示:
这仍然是一种解决方法,我无法弄清楚垂直/面板格式的对齐模型输出的视觉效果。通常,您要做的是在最终文档中排列并排表格。