[R-meta] forest plot with large number of studies

Viechtbauer Wolfgang (SP) wolfgang.viechtbauer at maastrichtuniversity.nl
Fri Aug 18 16:47:38 CEST 2017


Hi Roger,

Just use pdf(), png(), or whatever device you want to use and set 'width' and 'height' to something appropriate. You may also need to twiddle with some of the arguments for forest(), like psize, cex, efac, and so on, to make things look just right.

For example, for a meta-analysis we are working on, I created the attached forest plot. The side-by-side thing is of course something particular to this meta-analysis, but one could use the same approach for splitting up a very large number of studies into two (or more) columns.

The code for this was:

options(na.action = "na.pass")

cairo_pdf(file="forest_plot.pdf", width=8, height=16, family="Consolas")

psize  <- 1.2
cex    <- 0.4
efac   <- c(0, 0.5)
digits <- 3L
xlim   <- c(-14, 11)
col.a  <- rgb(215, 25, 28, max=255) # active = redish  color
col.p  <- rgb( 44,123,182, max=255) # placeb = blueish color
ylim   <- c(-1, nrow(dat)+3)
at     <- log(c(.001, .01, .1, 1, 10, 100))

par(mfrow=c(1,2))
par(mar=c(2.5,4,3,2), yaxs="i", tck=-0.015, mgp=c(1.5,0.1,0))

for (i in 1:2) {

   if (i == 1) {
      yi <- dat$yi1
      vi <- dat$vi1
      xlab <- "Odds of Attrition"
      main <- "Forest Plot for Attrition"
   } else {
      yi <- dat$yi2
      vi <- dat$vi2
      xlab <- "Odds of Abstinence"
      main <- "Forest Plot for Abstinence"
   }

   with(dat, forest(yi, vi, col=ifelse(group == "active", col.a, col.p), refline=NA, xlim=xlim, ylim=ylim, atransf=exp, at=at,
                    psize=psize, cex=cex, efac=efac, digits=digits, slab=paste0(author, " (", year, ") "), xlab=xlab))
   abline(h = 0.6 + (nrow(dat):1)[c(0,diff(dat$trial)) > 0], col="gray80", lwd=0.4)
   text(xlim[1], ylim[2] - 1, "Author (Year)", pos=4, cex=cex, font=2)
   text(xlim[2], ylim[2] - 1, "Odds [95% CI]", pos=2, cex=cex, font=2)
   title(main, cex.main=cex*1.6, line=2)

}

dev.off()

options(na.action = "na.omit")

This would of course need to be adjusted based on the dataset, but it might give you some ideas.

Best,
Wolfgang

-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-project.org] On Behalf Of Martineau, Roger
Sent: Friday, August 18, 2017 16:08
To: r-sig-meta-analysis at r-project.org
Subject: [R-meta] forest plot with large number of studies

Dear metafor users,

I downloaded the data set from  Assinka and Wibbelink (2016) available from http://www.tqmp.org/RegularArticles/vol12-3/p154/p154.pdf

The data set (i.e., p154-dataset.csv) contains 100 studies. Using the forest ( ) function on the multilevel model termed multiplemoderator (i.e., Listing 15), I got a crowded forest plot hard to interpret because there are too many studies. I even get a bigger problem on my own data sets with near to 300 studies.

Is there a way to produce a forest plot on 2 or more pages when needed for scrutinizing and printing?

Is there a good web site that shows how to adjust coordinates or change dimensions of the plotting device?

Thanks in advance,

Roger :)

Roger Martineau, mv Ph.D.
Centre de recherche et de d�veloppement
sur le bovin laitier et le porc
Agriculture et agroalimentaire Canada/Agriculture and Agri-Food Canada
T�l�phone/Telephone: 819-780-7319
T�l�copieur/Facsimile: 819-564-5507
2000, Rue Coll�ge / 2000, College Street
Sherbrooke (Qu�bec)  J1M 0C8
Canada
roger.martineau at agr.gc.ca<mailto:roger.martineau at agr.gc.ca>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: forest_plot.pdf
Type: application/pdf
Size: 47782 bytes
Desc: forest_plot.pdf
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20170818/12b972aa/attachment-0001.pdf>


More information about the R-sig-meta-analysis mailing list