Create labels for funnel plot points in metafor

label, plot, r

Solution

When browsing the sources of `rma()` and `funnel.rma()` (from version 1.9-2 of metafor), I cannot find any specific provisions in there for putting labels into the funnel plots. To draw your own labels, however, the positions appear to be in principle reproducible from the `rma`-object, so one might build on these numbers without having to recalculate everything. This approach will of course at least hinge on the chosen value of the `yaxis`-parameter, but by default `sqrt(vi) ~ yi` appears to work:

# ...
funnel(res, level=c(90, 95, 99), shade=c("white", "gray", "darkgray"), refline=0)
text(res$yi,sqrt(res$vi)+.016,res$slab,cex=.8)

Sometimes the graphical appearance may then of course suck as overlapping labels become unreadable.

Alternatively you might attempt to assign meaningful `pch`-values yourself (which should normally be integers), and try to explain these with a legend:

alloc.factor <- factor(dat.bcg$alloc) 
stopifnot(res$k==length(alloc.factor))
funnel(res, level=c(90, 95, 99), shade=c("white", "gray", "darkgray"), refline=0,
    pch=as.numeric(alloc.factor),lwd=2,cex=1.6)
legend("topright",levels(alloc.factor),pch=1:3,pt.lwd=2,cex=1.6)

Problem

Looking at the funnel plot examples, on the metafor page - it seems there is a way to add labels to the funnel plot. The funnel plot page provides more details, but it does not list an example for adding labels. The example provided: ``` library(metafor) png(filename="contour_enhanced_funnel_plot.png", res=92, width=680, height=600, type="cairo") par(mar=c(5,4,1,2)) data(dat.bcg) res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="RR", slab=paste(author, year, sep=", "), method="REML") funnel(res, level=c(90, 95, 99), shade=c("white", "gray", "darkgray"), refline=0) dev.off() ``` Includes a labels field, but none are generated in the example. How might I add labels to the funnel plot? Looking here, it seems that using pch might be an alternative. Something along the lines of: ``` pch=paste(StudyName, StudyMeasure, sep=", ") ``` but that just produces one letter dots. .

Original source