The metafor Package

A Meta-Analysis Package for R

User Tools

Site Tools


plots:meta_analytic_scatterplot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
plots:meta_analytic_scatterplot [2020/06/03 08:34] – [Code] Wolfgang Viechtbauerplots:meta_analytic_scatterplot [2021/04/25 13:11] Wolfgang Viechtbauer
Line 20: Line 20:
 res <- rma(yi, vi, mods = ~ ablat, data=dat) res <- rma(yi, vi, mods = ~ ablat, data=dat)
  
-### calculate predicted risk ratios for 0 to 60 degrees absolute latitude +### draw plot 
-preds <- predict(res, newmods=c(0:60), transf=exp) +regplot(res, xlim=c(10,60), predlim=c(10,60), xlab="Absolute Latitude", refline=0
- +        atransf=expat=log(seq(0.2,1.6,by=0.2))digits=1, las=1, bty="l", 
-### radius of points will be proportional to the inverse standard errors +        label=c(4,7,12,13), offset=c(1.6,0.8), labsize=0.9)
-### hence the area of the points will be proportional to inverse variances +
-size <- 1 / sqrt(dat$vi) +
-size <- size / max(size) +
- +
-### set up plot (risk ratios on y-axis, absolute latitude on x-axis) +
-plot(NA, NA, xlim=c(10,60), ylim=c(0.2,1.6), +
-     xlab="Absolute Latitude", ylab="Risk Ratio"+
-     las=1bty="l", log="y"+
- +
-### add points +
-symbols(dat$ablat, exp(dat$yi), circles=size, inches=FALSE, add=TRUE, bg="black"+
- +
-### add predicted values (and corresponding CI bounds) +
-lines(0:60preds$pred) +
-lines(0:60, preds$ci.lblty="dashed"+
-lines(0:60, preds$ci.ublty="dashed"+
- +
-### dotted line at RR=1 (no difference between groups) +
-abline(h=1, lty="dotted") +
- +
-### labels some points in the plot +
-ids <- c(4,7,12,13) +
-pos <- c(3,3,1,1) +
-text(dat$ablat[ids]exp(dat$yi)[ids], ids, cex=0.9, pos=pos)+
 </code> </code>
  
plots/meta_analytic_scatterplot.txt · Last modified: 2022/03/26 16:15 by Wolfgang Viechtbauer