A forest plot shows each study in a meta-analysis with its effect size and confidence interval. forestmap sorts the studies from the smallest to the largest effect and adds a heatmap underneath showing each study’s properties: its population, design, country, or anything else you’ve coded. Reading down a column tells you about one study; reading across a row tells you where studies with that property fall among the effects.
You need a data frame with one row per study and these columns:
| Column | What it holds |
|---|---|
| Effect size | The study’s effect, e.g. a standardised mean difference. |
| Sampling variance | The variance of that effect, e.g. vi from
metafor::escalc(). |
| One column per study property | A factor giving the study’s level, e.g. "RCT".
NA means the study doesn’t report it. |
The package comes with made-up data from 60 studies:
head(forestmap_example)
#> study smd vi n population outcome design
#> 1 Wang 2005 0.470 0.01581 253 Children <NA> RCT
#> 2 Hughes 2013 0.261 0.03704 108 Children Behavioural RCT
#> 3 Rossi 2005 0.510 0.04545 88 Adults Self-report Quasi-experimental
#> 4 Baker 2006 0.410 0.01493 268 Adults <NA> Quasi-experimental
#> 5 Hughes 2008 0.786 0.03077 130 Children Self-report RCT
#> 6 Martin 2023 0.260 0.06349 63 Adults <NA> RCT
#> country
#> 1 USA
#> 2 <NA>
#> 3 Canada
#> 4 Australia
#> 5 USA
#> 6 USAThe order of a factor’s levels sets the order of the rows in the
heatmap, so use factor(x, levels = ...) to change it.
If you’ve computed effect sizes with metafor’s
escalc(), your data already has the effect
(yi) and sampling variance (vi): pass them as
es = "yi", vi = "vi".
Instead of variances you can give standard errors
(se = "..."), or the lower and upper
bounds of each 95% confidence interval
(lb = "...", ub = "..."). Use the bounds when the interval
isn’t symmetric, such as odds ratios on their original scale. From
variances or standard errors, the interval is the effect ± 1.96 standard
errors.
Tell plot_forestmap() which column is which. Naming the
study properties sets the headings in the plot:
plot_forestmap(
forestmap_example,
es = "smd",
vi = "vi",
moderators = c(
"Population" = "population",
"Outcome measure" = "outcome",
"Study design" = "design",
"Country" = "country"
)
)
#> Found litedown! Enabling r-universe templateplot_forestmap() returns the plot; saving it is up to
you. Choose the size when you save:
p <- plot_forestmap(
forestmap_example, "smd", vi = "vi",
moderators = c("Population" = "population", "Study design" = "design")
)
ggplot2::ggsave("forestmap.png", p, width = 7, height = 5.25, dpi = 300)
ggplot2::ggsave("forestmap.svg", p, width = 7, height = 5.25)
ggplot2::ggsave("forestmap.pdf", p, width = 7, height = 5.25, device = cairo_pdf)With many study properties, make the plot taller
(e.g. height = 10).
The default font, Roboto Condensed, comes with forestmap, and PNG and
SVG files saved with ggsave() always use it. Two places
only see fonts installed on your computer, and show another font until
you install Roboto Condensed (the font files are in the folder given by
system.file("fonts", package = "forestmap")):
device = cairo_pdf as above.Customising the plot shows how to change the headings, colours, font, sizes and layout, with an example of each.