英文:
modelsummary: goodness-of-fit disappeares when the table shape is changed
问题
当我使用R包modelsummary时,我希望模型垂直排列,统计数据水平排列。shape的默认公式是term + statistic ~ model,正常表格是完整的。
mod_custom <- lm(hp ~ mpg + drat, mtcars)
modelsummary(mod_custom)
然而,当我将shape更改为model ~ term + statistic时,所有拟合度指标都消失了:
modelsummary(mod_custom,
shape = model ~ term + statistic,
)
我尝试过设置参数:
gof_omit = 'NULL'
或
gof_map = 'all'
但都没有起作用。我应该怎么做才能在更改shape时显示拟合度指标,例如AIC,或者是否有其他方法可以保留拟合度指标的情况下旋转表格?
英文:
When I use the R package modelsummary, I want the models to be vertically arragnged and the statistics to be horizontally. The default formula for shape is term + statistic ~ model, and the normal table is complete
mod_custom <- lm(hp ~ mpg + drat, mtcars)
modelsummary(mod_custom)
enter image description here. However, when I change the shape to be model ~term + statistic, all the goodness-of-fit disappears:
modelsummary(mod_custom,
shape=model ~term + statistic,
)
I have tried to set the parameter
gof_omit='NULL'
or
gof_map='all'
None of them worked. What should I do to make the goodness-of-fit ,such as AIC, display when the shape is changed or is there other methods to pivot the table with goodness-of-fit reserved?
答案1
得分: 1
我已经在 https://github.com/vincentarelbundock/modelsummary/issues/620 找到了启发性的答案。开发者尚未解决这个问题,所以只能通过 add_columns 来解决。方法如下:
mod_custom <- lm(hp ~ mpg + drat, mtcars)
cols <- broom::glance(mod_custom)
modelsummary(mod_custom,
shape = model ~ term + statistic,
add_columns = cols
)
英文:
I have found the answer inspiring by https://github.com/vincentarelbundock/modelsummary/issues/620. This issue has not been fixed by the developer, so it can only be solved by add_columns. The method is as follows.
mod_custom <- lm(hp ~ mpg + drat, mtcars)
cols<-broom::glance(mod_custom)
modelsummary(mod_custom,
shape=model ~term + statistic,
add_columns=cols,
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论