• Stars
    star
    778
  • Rank 56,061 (Top 2 %)
  • Language
    R
  • License
    GNU General Publi...
  • Created over 5 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Beautiful and customizable model summaries in R.





modelsummary creates tables and plots to present descriptive statistics and to summarize statistical models in R.

modelsummary is a package to summarize data and statistical models in R. It supports over one hundred types of models out-of-the-box, and allows users to report the results of those models side-by-side in a table, or in coefficient plots. It makes it easy to execute common tasks such as computing robust standard errors, adding significance stars, and manipulating coefficient and model labels. Beyond model summaries, the package also includes a suite of tools to produce highly flexible data summary tables, such as dataset overviews, correlation matrices, (multi-level) cross-tabulations, and balance tables (also known as “Table 1”). The appearance of the tables produced by modelsummary can be customized using external packages such as kableExtra, gt, flextable, or huxtable; the plots can be customized using ggplot2. Tables can be exported to many output formats, including HTML, LaTeX, Text/Markdown, Microsoft Word, Powerpoint, Excel, RTF, PDF, and image files. Tables and plots can be embedded seamlessly in rmarkdown, knitr, or Sweave dynamic documents. The modelsummary package is designed to be simple, robust, modular, and extensible (Arel-Bundock, 2022).

What?

modelsummary includes two families of functions:

  1. Model Summary
    • modelsummary: Regression tables with side-by-side models.
    • modelplot: Coefficient plots.
  2. Data Summary
    • datasummary: Powerful tool to create (multi-level) cross-tabs and data summaries.
    • datasummary_crosstab: Cross-tabulations.
    • datasummary_balance: Balance tables with subgroup statistics and difference in means (aka “Table 1”).
    • datasummary_correlation: Correlation tables.
    • datasummary_skim: Quick overview (“skim”) of a dataset.
    • datasummary_df: Turn dataframes into nice tables with titles, notes, etc.

Why?

Here are a few benefits of modelsummary over some alternative packages:

Easy

modelsummary is very easy to use. This simple call often suffices:

library(modelsummary)

mod <- lm(y ~ x, dat)

The command above will automatically display a summary table in the Rstudio Viewer or in a web browser. All you need is one word to change the output format. For example, a text-only version of the table can be printed to the Console by typing:

modelsummary(mod, output = "markdown")

Tables in Microsoft Word and LaTeX formats can be saved to file by typing:

modelsummary(mod, output = "table.docx")
modelsummary(mod, output = "table.tex")

Flexible

Information: The package offers many intuitive and powerful utilities to customize the information reported in a summary table. You can rename, reorder, subset or omit parameter estimates; choose the set of goodness-of-fit statistics to include; display various “robust” standard errors or confidence intervals; add titles, footnotes, or source notes; insert stars or custom characters to indicate levels of statistical significance; or add rows with supplemental information about your models.

Appearance: Thanks to the tinytable, gt, kableExtra, huxtable, flextable, and DT packages, the appearance of modelsummary tables is endlessly customizable. The appearance customization page shows tables with colored cells, weird text, spanning column labels, row groups, titles, source notes, footnotes, significance stars, and more. This only scratches the surface of possibilities.

Supported models: Thanks to the broom and parameters, modelsummary supports hundreds of statistical models out-of-the-box. Installing other packages can extend the capabilities further (e.g., broom.mixed). It is also very easy to add or customize your own models.

Output formats: modelsummary tables can be saved to HTML, LaTeX, Text/Markdown, Microsoft Word, Powerpoint, RTF, JPG, or PNG formats. They can also be inserted seamlessly in Rmarkdown documents to produce automated documents and reports in PDF, HTML, RTF, or Microsoft Word formats.

Dangerous

modelsummary is dangerous! It allows users to do stupid stuff like inserting squirrels in all your tables.

Reliable

modelsummary is reliably dangerous! The package is developed using a suite of unit tests with about 95% coverage, so it (probably) won’t break.

Community

modelsummary does not try to do everything. Instead, it leverages the incredible work of the R community. By building on top of the broom and parameters packages, modelsummary already supports hundreds of model types out-of-the-box. modelsummary also supports five of the most popular table-building and customization packages: gt, kableExtra, huxtable, flextable, and DT packages. By using those packages, modelsummary allows users to produce beautiful, endlessly customizable tables in a wide variety of formats, including HTML, PDF, LaTeX, Markdown, and MS Word.

One benefit of this community-focused approach is that when external packages improve, modelsummary improves as well. Another benefit is that leveraging external packages allows modelsummary to have a massively simplified codebase (relative to other similar packages). This should improve long term code maintainability, and allow contributors to participate through GitHub.

How?

You can install modelsummary from CRAN:

install.packages('modelsummary')

You can install the development version of modelsummary and its dependencies from R-Universe:

install.packages(
    c("modelsummary", "tinytable", "insight", "performance", "parameters"),
    repos = c(
        "https://vincentarelbundock.r-universe.dev",
        "https://easystats.r-universe.dev"))

Restart R completely before moving on.

Get started

The GET STARTED vignette will walk you through the basics of modelsummary.

You will find that there are a million ways to customize the tables and plots produced by modelsummary, but the Get Started page only scratches the surface. For details, see the vignettes:

More Repositories

1

countrycode

R package: Convert country names and country codes. Assigns region descriptors.
R
330
star
2

marginaleffects

R package to compute and plot predictions, slopes, marginal means, and comparisons (contrasts, risk ratios, odds, etc.) for over 80 classes of statistical models. Conduct linear and non-linear hypothesis tests, or equivalence tests. Calculate uncertainty estimates using the delta method, bootstrapping, or simulation-based inference.
R
290
star
3

Rdatasets

A collection of datasets originally distributed in R packages
HTML
242
star
4

WDI

R package to download World Bank data
R
198
star
5

rethinking2

HTML
69
star
6

pymarginaleffects

Python
43
star
7

Reinhart-Rogoff

Reinhart Rogoff replication files: Python stats with IPython notebook
Python
28
star
8

softbib

Software Bibliographies for R Projects
R
24
star
9

marginsplot

plot marginal effects and predicted values using the `margins` and `ggplot2` libraries for `R`
R
9
star
10

tinysnapshot

Snapshots for unit tests using the tinytest framework for `R`. Includes expectations to test base `R` and `ggplot2` plots as well as console output from `print()`.
R
9
star
11

ACMQ

Analyse Causale et Méthodes Quantitatives
CSS
8
star
12

violets

Violets are BLUE. OLS is too. (R package)
R
8
star
13

opic

Overseas Private Investment Corporation data on projects and insurance claims
R
7
star
14

SpatialHelper

A collection of helper functions for network analysis (TERGM) and spatial econometrics in R
R
4
star
15

modelarchive

Archive of `R` models used to test `{modelsummary}` and `{marginaleffects}`
2
star
16

pycountrycode

Python
2
star
17

regrets

R package to print facts and pictures of egrets
R
1
star
18

vincentarelbundock.github.io

Vincent's projects
CSS
1
star