简体   繁体   中英

Academic regression tables in the tidymodels workflow?

Is there any way to create a stargazer::stargazer() style (or something close to it) coef table using a broom::tidy() object? I have tried gt() but it doesn't seem tailored for publication-ready LaTeX/Rmd tables.

The modelsummary package is compatible with broom . It produces highly-customizable stargazer -style regression tables (and more,), which can be saved to many formats such as HTML, LaTeX. or Word: (Disclaimer. I am the maintainer.)

You can summarize models side-by-side as in stargazer by storing them in a list. Under the hood, modelsummary will use broom to extract coefficients and such:

library(modelsummary)
mod <- list(
    lm(mpg ~ hp, data = mtcars),
    lm(mpg ~ hp + drat, data = mtcars))

modelsummary(mod)

在此处输入图像描述

If you want to work from raw broom::tidy object, you can also do it by creating a named list of class modelsummary_list . This second option allows you to use the default broom output, or to modify the broom output manually, or to create your own.

Example:

mod <- list(
    tidy = broom::tidy(mod),
    glance = broom::glance(mod))
class(mod) <- c("modelsummary_list", class(mod))

modelsummary(mod)

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM