<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear metafor community,<div class=""><br class=""></div><div class="">I recently had the very honour to dig through R code in order to set up a meta-regression scatterplot in ggplot2. As this experience was … interesting for me, but doesn’t warrant to be repeated by anyone else, I allow myself to send my approach to this honorable mailing list, for further use as deemed appropriate. @Wolfgang Viechtbauer: of course you may add this code (if it seems worth it) to your code examples on <a href="http://www.metafor-project.com" class="">www.metafor-project.com</a>.</div><div class=""><br class=""></div><div class="">Calculations are closely based on and expand the example of a meta-analytic scatterplot as shown on the website <a href="http://www.metafor-project.org/doku.php/plots:meta_analytic_scatterplot" class="">http://www.metafor-project.org/doku.php/plots:meta_analytic_scatterplot</a></div><div class=""><br class=""></div><div class="">In order to gain access to all necessary parameters, confidence interval boundaries are extracted from the escalc() function by</div><div class="">plot.dat <- summary.escalc(dat)</div><div class="">which generates a data.table() with effect size yi, variance vi, standard error and confidence interval boundaries ci.lb and ci.ub.</div><div class=""><br class=""></div><div class="">The data can then be put in the ggplot() syntax as following:</div><div class=""><br class=""></div><div class="">ggplot(plot.dat, aes(ablat, exp(yi)))</div><div class="">+ geom_point(pch = 19, cex = 1.5 * sizex) # as, to my experience, ggplot() will render dots smaller than the plot() function</div><div class="">+ geom_linerange(aes(ymin = exp(plot.dat$ci.lb), 
                    ymax = exp(plot.dat$ci.ub)),
                size = .25) # gives straight lines w/o brackets at the ends. if „classical“ look is preferred, use geom_errorbar()</div><div class="">+
  scale_y_continuous(trans = log_trans(),
                     limits = c(0.2, 1.6)) # for adjustment of axes, see (as example) <a href="http://www.cookbook-r.com/Graphs/" class="">http://www.cookbook-r.com/Graphs/</a></div><div class="">+
  xlab("Absolute Latitude“) </div><div class="">+
  ylab("risk ratio“)</div><div class="">+
  geom_hline(yintercept = 1, linetype = "dotted“) # draws the dotted line at y = 1 for equal risk ratio</div><div class="">+
  geom_line(data = preds, aes(x = preds$ablat, y = preds$pred)) # plots the regression line</div><div class="">+
  geom_line(data = preds, aes(x = preds$ablat, y = preds$ci.lb), linetype = "dashed“) # plots the lower confidence interval boundary</div><div class="">+
  geom_line(data = preds, aes(x = preds$ablat, y = preds$ci.ub), linetype = "dashed“) # plots the upper confidence interval boundary</div><div class=""><br class=""></div><div class="">Labeling of individual data points was not in the scope of my work, but could be done by the geom_text(aes(label = label)) command.</div><div class=""><br class=""></div><div class="">Hope this helps.</div><div class=""><br class=""></div><div class="">Cheers</div><div class="">Moritz</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; border-spacing: 0px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">--</div><div class="">Dr. med. Moritz Tobiasch</div><div class=""><br class=""></div><div class="">Kirchgasse 22b</div><div class="">A-6020 Innsbruck</div><div class="">Austria</div><div class=""><br class=""></div><div class="">Tel.: +43 650 5667954</div><div class=""><a href="mailto:moritztobiasch@gmail.com" class="">moritztobiasch@gmail.com</a></div><div class=""><br class=""></div></div></span><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br class=""></div></body></html>