Following the example below, I want to write custom names of the column headers for the statistics and estimates: “Estimate”, “95% CI”, and “p value”. Ideally, I would like to obtain a table where each of these three elements have their own column, so it is easier to align each of them. Is this possible with {modelsummary}? I want a table optimized for latex and html.

library(modelsummary)
m1 <- lm(mpg ~ cyl + disp, mtcars)
m2 <- lm(wt ~ cyl + disp, mtcars)

msummary(list("M1" = m1, "M2" = m2),
         shape = term ~ model + statistic,
         statistic = "{p.value}",
         estimate = "{estimate} [{conf.low}; {conf.high}]")
M1 / Est. M1 / p M2 / Est. M2 / p
(Intercept) 34.661 [29.452; 39.870] <0.001 1.773 [0.983; 2.563] <0.001
cyl -1.587 [-3.043; -0.131] 0.034 -0.054 [-0.275; 0.166] 0.618
disp -0.021 [-0.042; 0.000] 0.054 0.008 [0.005; 0.011] <0.001
Num.Obs. 32 32
R2 0.760 0.790
R2 Adj. 0.743 0.776
AIC 167.1 46.4
BIC 173.0 52.3
Log.Lik. -79.573 -19.205
F 45.808 54.661
RMSE 2.91 0.44

The expected table would look like this:

M1 / Estimate M1 / 95% CI M1 / p value M2 / Estimate M2 / 95% CI M2 / p value
(Intercept) 34.661 [29.452; 39.870] <0.001 1.773 [0.983; 2.563] <0.001
cyl -1.587 [-3.043; -0.131] 0.034 -0.054 [-0.275; 0.166] 0.618

You can put all the statistics individually in a vector in the statistic argument and then use shape to place them in columns:

library(modelsummary)
m1 <- lm(mpg ~ cyl + disp, mtcars)
m2 <- lm(wt ~ cyl + disp, mtcars)
mod <- list("M1" = m1, "M2" = m2)

msummary(mod,
  escape = TRUE,
  shape = term ~ model + statistic,
  estimate = "estimate",
  statistic = c("p.value", "conf.low", "conf.high"))

enter image description here

enter image description here

Warning: In LaTeX, the confidence interval headers do not appear to be properly escaped, and the raw % signs break compilation of the documents. I had to go in and add a backslash in front: %

I opened an issue on the modelsummary package Github: https://github.com/vincentarelbundock/modelsummary/issues/696