I want to have my fixed effects capitalized in the modelsummary
output. While I know I could rename the columns before estimating the regression, I wanted to know if there is an easier way to do this within the modelsummary::modelsummary
function. I have tried the coef_map
argument, but it doesn't seem to affect the table.
library(tidyverse)
library(modelsummary)
library(fixest)
mtcars %>%
feols(mpg ~hp | gear, data = .) %>%
modelsummary(stars = T, coef_map = c("hp" = "Horsepower",
"mpg" = 'MPG',
"gear" = "Gear"))
As shown in the example, I want the "gear" fixed effect to be capitalized without having to rename in my data (if possible).
CodePudding user response:
A modelsummary
table is essentially composed of two parts. The top contains estimates and is controlled by the coef_*
arguments. The bottom contains “goodness-of-fit” and other model characteristics, and is controlled by the gof_*
arguments.
You can rename and reformat and reorder the GOF info with the gof_map
argument. In this example, I use the tribble
function to create a data.frame
with the information needed to rename and capitalize. You can also use a list, or a plain data.frame
. Please refer to the documentation.
library(tidyverse)
library(modelsummary)
library(fixest)
gm <- tribble(~raw, ~clean, ~fmt,
"FE: gear", "FE: Gear", ~fmt)
mtcars %>%
feols(mpg ~hp | gear, data = .) %>%
modelsummary(output = "markdown",
stars = T, coef_map = c("hp" = "Horsepower",
"mpg" = 'MPG',
"gear" = "Gear"),
gof_map = gm)
Model 1 | |
---|---|
Horsepower | -0.067* |
(0.016) | |
FE: Gear | X |
Note: ^^ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001