rmodelsummary

How can I rename statistics in modelsummary?


I have a model and I like the following format from model summary:

library(modelsummary)

fit <- lm(am ~ vs, data=mtcars)

modelsummary(
  fit,
  statistic = c('std.error', 'p.value', 'conf.int'),
  gof_map = NA,
  shape= term ~ statistic
)

However, the confidence interval limits are referred to as 2.5% and 97.5%. Can I somehow rename them to something like "CI Lower/Upper"?


Solution

  • Version 2.0.0 of modelsummary will be released in the next few days with built-in support for this. You can install it now with:

    library(remotes)
    install_github("vincentarelbundock/modelsummary")
    

    Then,

    library(modelsummary)
    
    fit <- lm(am ~ vs, data=mtcars)
    
    modelsummary(
      fit,
      statistic = c(
        'Std.Error' = 'std.error', 
        'P val' = 'p.value', 
        'Lower' = 'conf.low',
        'Upper' = 'conf.high'),
      gof_map = NA,
      shape= term ~ statistic
    )
    
    +-------------+-------+-----------+-------+--------+-------+
    |             | (1)                                        |
    +-------------+-------+-----------+-------+--------+-------+
    |             | Est.  | Std.Error | P val | Lower  | Upper |
    +=============+=======+===========+=======+========+=======+
    | (Intercept) | 0.333 | 0.118     | 0.008 | 0.093  | 0.574 |
    +-------------+-------+-----------+-------+--------+-------+
    | vs          | 0.167 | 0.178     | 0.357 | -0.197 | 0.531 |
    +-------------+-------+-----------+-------+--------+-------+