代码之家  ›  专栏  ›  技术社区  ›  ly li

模型摘要:当表格形状改变时,拟合优度消失

  •  0
  • ly li  · 技术社区  · 1 年前

    当我使用R包模型摘要时,我希望模型是垂直排列的,统计数据是水平排列的。的默认公式 形状 术语+统计~模型 ,并且正常的表格是完整的

    mod_custom <- lm(hp ~ mpg + drat, mtcars)
    modelsummary(mod_custom)
    

    enter image description here 。但是,当我将形状更改为 模型~术语+统计 ,所有的贴合感都消失了:

    modelsummary(mod_custom,
                 shape=model ~term + statistic,
                 )
    

    enter image description here

    我已尝试设置参数

    gof_omit='NULL'
    

    gof_map='all'
    

    它们都不起作用。当形状发生变化时,我应该怎么做才能显示拟合优度,例如AIC,或者是否有其他方法可以在保留拟合优度的情况下透视表?

    1 回复  |  直到 1 年前
        1
  •  1
  •   ly li    1 年前

    我发现答案鼓舞人心 https://github.com/vincentarelbundock/modelsummary/issues/620 。此问题尚未由开发人员解决,因此只能通过 添加列(_co) 方法如下。

    mod_custom <- lm(hp ~ mpg + drat, mtcars)
    cols<-broom::glance(mod_custom)
    modelsummary(mod_custom, 
                 shape=model ~term + statistic,
                 add_columns=cols,
                 )
    

    enter image description here