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

huangapple go评论100阅读模式
英文:

modelsummary: goodness-of-fit disappeares when the table shape is changed

问题

当我使用R包modelsummary时,我希望模型垂直排列,统计数据水平排列。shape的默认公式是term + statistic ~ model,正常表格是完整的。

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

然而,当我将shape更改为model ~ term + statistic时,所有拟合度指标都消失了:

  1. modelsummary(mod_custom,
  2. shape = model ~ term + statistic,
  3. )

我尝试过设置参数:

  1. gof_omit = 'NULL'

  1. 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

  1. mod_custom &lt;- lm(hp ~ mpg + drat, mtcars)
  2. modelsummary(mod_custom)

enter image description here. However, when I change the shape to be model ~term + statistic, all the goodness-of-fit disappears:

  1. modelsummary(mod_custom,
  2. shape=model ~term + statistic,
  3. )

enter image description here

I have tried to set the parameter

  1. gof_omit=&#39;NULL&#39;

or

  1. gof_map=&#39;all&#39;

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 来解决。方法如下:

  1. mod_custom <- lm(hp ~ mpg + drat, mtcars)
  2. cols <- broom::glance(mod_custom)
  3. modelsummary(mod_custom,
  4. shape = model ~ term + statistic,
  5. add_columns = cols
  6. )

图片描述见链接

英文:

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.

  1. mod_custom &lt;- lm(hp ~ mpg + drat, mtcars)
  2. cols&lt;-broom::glance(mod_custom)
  3. modelsummary(mod_custom,
  4. shape=model ~term + statistic,
  5. add_columns=cols,
  6. )

enter image description here

huangapple
  • 本文由 发表于 2023年6月18日 21:41:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76500847.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定