[R-meta] metafor forest 'ylim()': 1.row distances change, 2 .relative lines?

Viechtbauer, Wolfgang (SP) wolfg@ng@viechtb@uer @ending from m@@@trichtuniver@ity@nl
Mon Sep 24 10:04:37 CEST 2018


Of course the distances change in absolute terms. The dimensions of the plotting device are the same, so how else would one fit k=4 vs k=7 studies into the same space without the points falling closer to each other? If you want to keep the same distances, then you have to make the size of the plotting device smaller/larger.

See also: https://stackoverflow.com/questions/25565817/align-text-to-a-plot-with-variable-size-in-r

Best,
Wolfgang

-----Original Message-----
From: P. Roberto Bakker [mailto:robertobakker using gmail.com] 
Sent: Monday, 24 September, 2018 8:51
To: Viechtbauer, Wolfgang (SP)
Cc: r-sig-meta-analysis using r-project.org
Subject: Re: [R-meta] metafor forest 'ylim()': 1.row distances change, 2 .relative lines?

Hi Wolfgang,

My apologies, I did something wrong with registering. Now it should be okay. 

Thank you for your explaination. Very clear. 

Still the study row distances change when the number of studies change (see A next to B here below).
The journal asks for same distances. 
As my meta-analyses are for different medication groups (each with different number of studies) the study row distances vary between meta-analyses.
So, what could I do?
Thank you in advance, 
Roberto
###########A###############
yi <- c(.1, .3, .2, .5)
vi <- rep(.01, 4)
res <- rma(yi, vi)
forest(res)

### default for ylim is -1.5 to k+3
### summary polygon in y=-1
### line in y=0
### studies in y=1 to k
### line in y=k+1
forest(res, ylim=c(-1.5,res$k+3))
text(0, -1:7, -1:7)

############B###############
yi <- c(.1, .3, .2, .5, .6, .5, .4)
vi <- rep(.01, 7)
res <- rma(yi, vi)
forest(res)

### default for ylim is -1.5 to k+3
### summary polygon in y=-1
### line in y=0
### studies in y=1 to k
### line in y=k+1
forest(res, ylim=c(-1.5,4))
text(0, -1:7, -1:20)
###########################

Op zo 23 sep. 2018 om 19:28 schreef Viechtbauer, Wolfgang (SP) <wolfgang.viechtbauer using maastrichtuniversity.nl>:
Maybe this helps -- go through this line by line.

yi <- c(.1, .3, .2, .5)
vi <- rep(.01, 4)
res <- rma(yi, vi)
forest(res)

### default for ylim is -1.5 to k+3
### summary polygon in y=-1
### line in y=0
### studies in y=1 to k
### line in y=k+1
forest(res, ylim=c(-1.5,res$k+3))
text(0, -1:7, -1:7)

### change ylim
forest(res, ylim=c(-3,10))
text(0, -3:10, -3:10)

### this creates more space which we indicate subgroups and/or to add extra summary polygons
forest(res, ylim=c(-3,10), row=c(6,5,2,1))
text(0, -3:10, -3:10)
text(par()$usr[1], 7, "Group A", font=2, pos=4)
text(par()$usr[1], 3, "Group B", font=2, pos=4)
addpoly(rma(yi, vi, subset=1:2), row=-2, mlab="Group A")
addpoly(rma(yi, vi, subset=3:4), row=-3, mlab="Group A")

Best,
Wolfgang

-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On Behalf Of P. Roberto Bakker
Sent: Sunday, 23 September, 2018 12:01
To: r-sig-meta-analysis using r-project.org
Subject: [R-meta] metafor forest 'ylim()': 1.row distances change, 2 .relative lines?

Hi

When I change 'ylim()', two things happen that I do not understand:

1) The study row distances change:
- e.g. When I change from 'ylim=c(-1, 23)' into 'ylim=c(-1, 10)',  then
'y=c(-1, 5)', etc
-> the study row distances increase at every step
This whould not be a problem if I had only one forest plot - but I have
several forest plots - so between forestplots the study row distances are
different.
'rows=c()' could be a solution, however, the study row distances between
forestplots still may differ.

2. The position of both horizontal lines change when I change one.
e.g. at every step shown aboven the lower line changes position - the
summary polygon may even disappear

All in all, I seems to me that 'ylim()' zooms in/out at every change.

In short: when I change one thing 'all other things change'.

I hope I am clear.

Syntax:
forest(res, slab = paste(datsub$npd, datsub$tn, sep = ", "),
         cex =0.45, cex.lab=0.8, cex.main=0.8, main="MAOI vs placebo - REML
- R=0.5",
         showweights = TRUE, order=order(datsub$name),
         ylim=c(-1,23))

On my laptop: surface pro 4 64b
R version 3.5.0 (2018-04-23) -- "Joy in Playing"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)


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