36  Coefficient plots and forest plots

A regression with several predictors produces a table of coefficients, each with an estimate, a standard error, a confidence interval, and a p-value. Reading such a table requires the reader to compare numbers across rows mentally; it is hard to see at a glance which predictors are large, which are small, and which are uncertain. The coefficient plot (sometimes called a dot-and-whisker plot, a coefplot, or, in its meta-analytic form, a forest plot) puts the same information into a single visual element. One row per coefficient, a dot at the point estimate, a horizontal line for the 95% confidence interval, and a vertical reference line at zero. Once you have seen one, regression tables start to feel obsolete for many purposes.

This chapter explains what coefficient plots show, builds them in R from scratch, and shows the meta-analytic forest plot variant.

36.1 What a coefficient plot shows

A coefficient plot is a visual summary of a model. Each row is a coefficient. The dot is the point estimate. The horizontal line is the 95% confidence interval. A vertical dashed line at zero is the reference. If the line does not cross zero, the coefficient is statistically significantly different from zero at α = .05. The width of the line is the precision: narrow lines are precise estimates, wide lines are imprecise.

Three things become immediately visible:

  • Which coefficients are far from zero. The eye is drawn to the rows whose lines are entirely on one side of zero.
  • How precise each estimate is. Long lines mean the estimate is consistent with a wide range of values.
  • Which coefficients are comparable in magnitude. When coefficients are on the same scale (standardized, or in the same units), comparing dot positions across rows is a meaningful comparison.

The coefficient plot is most useful when there are several predictors of similar interest. For one or two predictors, an effect-size estimate with its CI in the prose is enough. For five or ten, the plot is a strict improvement over the table.

36.2 Building a coefficient plot from scratch

Let us build one for a multiple regression on vgames_study.

vgames <- read.csv("data/vgames_study.csv")

Fit a model with several predictors:

fit <- lm(aggression ~ condition + trait_hostility + empathy + hours_weekly,
          data = vgames)
summary(fit)

Call:
lm(formula = aggression ~ condition + trait_hostility + empathy + 
    hours_weekly, data = vgames)

Residuals:
    Min      1Q  Median      3Q     Max 
-3.1762 -0.6435 -0.0690  0.7468  2.5724 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)       2.99626    0.95006   3.154 0.002057 ** 
conditionviolent  1.93588    0.21636   8.948 7.32e-15 ***
trait_hostility   0.44909    0.12115   3.707 0.000324 ***
empathy          -0.36042    0.13413  -2.687 0.008277 ** 
hours_weekly      0.12816    0.02015   6.361 4.21e-09 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.123 on 115 degrees of freedom
Multiple R-squared:  0.529, Adjusted R-squared:  0.5126 
F-statistic: 32.29 on 4 and 115 DF,  p-value: < 2.2e-16

Extract the coefficient estimates and CIs:

if (requireNamespace("broom", quietly = TRUE)) {
  library(broom)
  coef_df <- tidy(fit, conf.int = TRUE) |>
    filter(term != "(Intercept)")
} else {
  # Manual extraction without broom
  est <- coef(fit)
  ci  <- confint(fit)
  coef_df <- data.frame(
    term     = names(est),
    estimate = unname(est),
    conf.low = ci[, 1],
    conf.high = ci[, 2]
  ) |>
    filter(term != "(Intercept)")
}

coef_df
# A tibble: 4 × 7
  term             estimate std.error statistic  p.value conf.low conf.high
  <chr>               <dbl>     <dbl>     <dbl>    <dbl>    <dbl>     <dbl>
1 conditionviolent    1.94     0.216       8.95 7.32e-15   1.51      2.36  
2 trait_hostility     0.449    0.121       3.71 3.24e- 4   0.209     0.689 
3 empathy            -0.360    0.134      -2.69 8.28e- 3  -0.626    -0.0947
4 hours_weekly        0.128    0.0201      6.36 4.21e- 9   0.0883    0.168 

broom::tidy() returns a clean data frame with one row per term and columns for the estimate, SE, statistic, p-value, and confidence interval. If broom is unavailable, the same information can be assembled from coef() and confint() by hand.

Now the plot:

coef_df$term <- factor(coef_df$term,
                       levels = rev(coef_df$term))

ggplot(coef_df, aes(x = estimate, y = term)) +
  geom_vline(xintercept = 0, linetype = "dashed",
             color = "grey40") +
  geom_errorbarh(aes(xmin = conf.low, xmax = conf.high),
                 height = 0, linewidth = 0.7,
                 color = "steelblue4") +
  geom_point(size = 3, color = "steelblue") +
  labs(x = "Coefficient estimate (95% CI)",
       y = NULL) +
  theme_minimal(base_size = 11) +
  theme(panel.grid.minor = element_blank())
Figure 36.1

The dashed grey line at zero is the reference. Each predictor has a dot at its point estimate and a horizontal line spanning its 95% CI. A predictor whose CI does not cross zero is statistically significant at α = .05; a predictor whose CI crosses zero is not. The reader can see, at a glance, that some predictors have large coefficients (long distance from zero) while others have small ones, and that some are estimated with high precision (narrow CI) while others are uncertain (wide CI).

The plot is more informative than the corresponding table for one specific kind of question: which predictors are doing the substantive work in the model, and how reliably? This is the kind of question readers most commonly want to answer when scanning a regression output.

36.3 Standardized vs unstandardized coefficients

The plot above mixes coefficients on different scales: condition is a 0/1 dummy, trait_hostility is on a 1-7 scale, empathy is on a 1-7 scale, and hours_weekly is in hours. A coefficient of 1.0 on hours_weekly is not commensurable with a coefficient of 1.0 on the dummy. Comparing dot positions across these rows is misleading.

For a fair comparison, plot standardized coefficients (β, Chapter 27 section 27.5), which scale every predictor to standard-deviation units.

if (requireNamespace("effectsize", quietly = TRUE)) {
  library(effectsize)
  std <- standardize_parameters(fit)
  std_df <- data.frame(
    term      = std$Parameter,
    estimate  = std$Std_Coefficient,
    conf.low  = std$CI_low,
    conf.high = std$CI_high
  ) |>
    filter(term != "(Intercept)")
  std_df$term <- factor(std_df$term, levels = rev(std_df$term))

  ggplot(std_df, aes(x = estimate, y = term)) +
    geom_vline(xintercept = 0, linetype = "dashed",
               color = "grey40") +
    geom_errorbarh(aes(xmin = conf.low, xmax = conf.high),
                   height = 0, linewidth = 0.7,
                   color = "firebrick4") +
    geom_point(size = 3, color = "firebrick") +
    labs(x = "Standardized coefficient (beta, 95% CI)",
         y = NULL) +
    theme_minimal(base_size = 11) +
    theme(panel.grid.minor = element_blank())
} else {
  cat("(effectsize not installed; the figure would show the same plot in beta units.)\n")
}
Figure 36.2

Now all the coefficients are in standard-deviation units, and comparing dot positions across rows is meaningful: a β of 0.4 versus a β of 0.1 directly tells you that the first predictor matters about four times as much per SD as the second, in the context of this model. This is the version of the coefficient plot most useful for substantive interpretation when the predictors are on different scales.

36.4 Renaming and reordering for clarity

The default coefficient names from R (conditionviolent, trait_hostility, etc.) are programmer-friendly but not reader-friendly. A polished plot has descriptive labels and a substantively meaningful ordering of rows.

renames <- c(
  conditionviolent  = "Condition (violent vs neutral)",
  trait_hostility   = "Trait hostility",
  empathy           = "Empathy",
  hours_weekly      = "Hours of weekly gameplay"
)

coef_df$label <- renames[as.character(coef_df$term)]
coef_df$label <- factor(coef_df$label,
                        levels = rev(c(
                          "Condition (violent vs neutral)",
                          "Trait hostility",
                          "Empathy",
                          "Hours of weekly gameplay"
                        )))

ggplot(coef_df, aes(x = estimate, y = label)) +
  geom_vline(xintercept = 0, linetype = "dashed",
             color = "grey40") +
  geom_errorbarh(aes(xmin = conf.low, xmax = conf.high),
                 height = 0, linewidth = 0.7,
                 color = "steelblue4") +
  geom_point(size = 3, color = "steelblue") +
  labs(x = "Coefficient estimate (95% CI)",
       y = NULL,
       title = "Predictors of aggression in vgames_study") +
  theme_minimal(base_size = 11) +
  theme(plot.title = element_text(face = "bold", size = 11),
        panel.grid.minor = element_blank())
Figure 36.3

Two small things have changed. The coefficient labels are now descriptive English rather than the raw names from R’s output. The ordering of rows is substantive (the experimental manipulation at the top, individual differences below it, exposure last). Both make the figure easier to read at a glance.

When the model has many coefficients, an additional improvement is to color-code or facet by predictor type (categorical vs continuous, or theoretically motivated vs control), and to sort within each facet by effect magnitude. The general principle is that the reader should be able to read the plot top to bottom and immediately understand the conceptual structure of the model.

36.5 Forest plots: the meta-analytic cousin

The forest plot is the same visualization applied to a different problem: summarizing the effect-size estimates across multiple studies. We saw one in Chapter 27 (section 27.8). Each row is one study; the dot is its effect-size estimate; the line is the 95% CI; the size of the dot can be scaled to the study’s weight in the meta-analysis. The pooled meta-analytic estimate is shown as a diamond at the bottom (or, in some conventions, as a separate larger dot).

# Hypothetical meta-analytic data
forest_data <- data.frame(
  study  = c("Original (vgames_study)",
             "Replication 1 (Anderson lab)",
             "Replication 2 (Bushman lab)",
             "Replication 3 (Ferguson lab)",
             "Replication 4 (multi-site RR)"),
  d      = c(0.85, 0.72, 1.02, 0.31, 0.58),
  se     = c(0.183, 0.180, 0.200, 0.255, 0.110)
)
forest_data$lower <- forest_data$d - 1.96 * forest_data$se
forest_data$upper <- forest_data$d + 1.96 * forest_data$se
forest_data$weight <- 1 / forest_data$se^2

# Fixed-effect meta-analytic pool
w <- forest_data$weight
pooled_d  <- sum(w * forest_data$d) / sum(w)
pooled_se <- sqrt(1 / sum(w))
pooled_row <- data.frame(
  study = "Meta-analytic estimate",
  d     = pooled_d,
  se    = pooled_se,
  lower = pooled_d - 1.96 * pooled_se,
  upper = pooled_d + 1.96 * pooled_se,
  weight = NA
)
all_rows <- rbind(forest_data, pooled_row)
all_rows$study <- factor(all_rows$study, levels = rev(all_rows$study))
all_rows$is_pooled <- c(rep(FALSE, 5), TRUE)
all_rows$msize <- ifelse(all_rows$is_pooled, 5,
                         2 + 5 * all_rows$weight /
                             max(all_rows$weight, na.rm = TRUE))

ggplot(all_rows, aes(y = study, x = d)) +
  geom_vline(xintercept = 0, color = "grey50", linetype = "dashed") +
  geom_errorbarh(aes(xmin = lower, xmax = upper),
                 height = 0, linewidth = 0.6) +
  geom_point(data = subset(all_rows, !is_pooled),
             aes(size = msize), shape = 15,
             color = "steelblue") +
  geom_point(data = subset(all_rows, is_pooled),
             shape = 23, fill = "firebrick", color = "firebrick",
             size = 4) +
  scale_size_identity() +
  labs(x = "Standardized effect size (Cohen's d, 95% CI)",
       y = NULL,
       title = "Forest plot of vgames_study and replications") +
  theme_minimal(base_size = 11) +
  theme(plot.title = element_text(face = "bold", size = 11),
        panel.grid.minor = element_blank())
Figure 36.4

Same visual logic as a coefficient plot, applied to a meta-analytic question instead of a regression model. The size of each square is scaled to the inverse-variance weight (larger squares contribute more to the pooled estimate). The bottom row, in red, is the pooled meta-analytic estimate from a fixed-effect model. The CI on the pooled estimate is much narrower than any individual study, reflecting the precision gain from combining evidence.

The forest plot’s visual logic is so successful that meta-analyses in psychology and medicine almost universally use it. For a deeper treatment of meta-analytic forest plots, see Borenstein, Hedges, Higgins, and Rothstein (2021).

36.6 A coding intuition

Every coefficient and forest plot has the same skeleton:

  1. A horizontal x axis representing the effect-size scale (coefficient value, standardized coefficient, Cohen’s d).
  2. A y axis representing rows (coefficients, studies).
  3. A vertical reference line at the null value (usually zero).
  4. A horizontal CI line for each row.
  5. A dot at the point estimate.

The ggplot code, accordingly, is always essentially the same:

ggplot(my_data, aes(x = estimate, y = label)) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) +
  geom_point()

Everything else (colors, sizes, themes, titles, ordering) is decoration. Once you have written the skeleton once, every coefficient plot or forest plot you ever build is a small modification of that template.

36.7 Check your understanding

1. What does a coefficient plot show and why is it useful?

2. When are standardized coefficients useful in a coefficient plot, and why?

3. What does a forest plot show?

4. What is the role of the vertical reference line at zero in a coefficient plot?

5. What is the problem with comparing unstandardized coefficient magnitudes across predictors of different types in a coefficient plot?

36.8 References

Borenstein, M., Hedges, L. V., Higgins, J. P. T., & Rothstein, H. R. (2021). Introduction to meta-analysis (2nd ed.). Wiley. https://doi.org/10.1002/9781119558378

Robinson, D., Hayes, A., & Couch, S. (2024). broom: Convert statistical objects into tidy tibbles [R package]. https://CRAN.R-project.org/package=broom