4  Regression tables

4.1 Linear regression: tbl_regression()

Compared with the output of summary(m_lm),

  • variable names are replaced by labels
  • for categorical variables, the row for the reference category is shown with “—”
  • coefficients, 95% confidence intervals, and p-values are lined up

4.2 Logistic regression: showing odds ratios

exponentiate = TRUE exponentiates the coefficients and shows them as odds ratios (OR). The header automatically becomes “OR” too.

4.3 Cox regression: showing hazard ratios

TipSupported models

Many models that broom can tidy are supported, including lm, glm, coxph, survreg, lme4::lmer / glmer, geepack::geeglm, and nnet::multinom.

4.4 Adjusting the display

4.5 Overall p-values for categorical variables: add_global_p()

For categorical variables with three or more levels (such as grade), this gives a p-value for “whether the variable as a whole has an effect” (likelihood-ratio or Wald test).

Instead of p-values for each level, one p-value is shown on the variable’s row (keep = TRUE shows both).

4.6 Model information in a footnote: add_glance_source_note()

4.7 Univariable regressions at once: tbl_uvregression()

Builds “models entering each variable one at a time” (univariable analyses, crude odds ratios) in one go.

The N column is the number of people (non-missing) used in each model.

4.8 Univariable and multivariable side by side (a staple of papers)

4.9 Significance stars: add_significance_stars()

The thresholds for * are shown in the footnote.

ImportantChapter summary
  • Turn a model into a table with tbl_regression(). exponentiate = TRUE for OR / HR
  • add_global_p() (p-value for the whole variable), add_glance_source_note() (R², etc.)
  • tbl_uvregression() for univariable analyses in bulk; tbl_merge() to place univariable and multivariable results side by side