Search code examples
rstatisticsr-forestplotmetafor

Remove Ticks on End of CIs in Forest Plot Metafor


I have a foresplot in r using the metafor package:

#forestplot
par(mar=c(2.75,0,0,0))
par(font=2,mgp=c(2.3, 0.8, 0), xaxs = "i")
metafor::forest.rma(res, alim=c(-1, 3.75), xlim = c(-5, 3.5), at = 
c(-1, -.5, 0 , .5, 1, 1.5, 2, 2.5, 3), xlab = "Cohen's D with 95% CI",  
slab = data$Author, annotate = FALSE,
              cex=.6, cex.lab = 0.5, refline = 0.68)

Foresplot

I would like to remove the ticks at the end of the confidence intervals for each observation but haven't found a clear way of doing so. In others words, have the confidence intervals just be horizontal lines, no vertical like at the end. Would anyone have any ideas on how to this?


Solution

  • Set the efac argument of metafor::forest.rma to c(0,1): the first value is the vertical expansion factor for CI limits and arrows; the second is for summary estimates.

    library(metafor)
    res <- rma(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg,
               slab=paste(author, year, sep=", "))
    
    par(mar=c(2.75,0,0,0))
    par(font=2,mgp=c(2.3, 0.8, 0), xaxs = "i")
    forest(res, alim=c(-1, 3.75), xlim = c(-5, 3.5), at = 
    c(-1, -.5, 0 , .5, 1, 1.5, 2, 2.5, 3), xlab = "Cohen's D with 95% CI",  
    annotate = FALSE, cex=0.8, cex.lab=0.8, refline = 0.68, efac=c(0,1))
    

    enter image description here