[R-meta] Adding vertical space to forest.rma plot

James Rae james.rae at psy.ox.ac.uk
Mon Oct 2 13:03:13 CEST 2017


Hello,

I'm editing a proof for publication. The paper reports a meta-analysis of 5 studies I conducted, an analysis that I conducted using the metafor package in R. I then plotted by results using the "forest.rma" function.

My problem is that the journal believes that the vertical alignment in the plot is inefficient. That is, there is too much white space between the study entries (and also the summary statistic that I report in the bottom of the plot). I've tried to change this by adjusting the "ylim" argument in the "forest.rma" function with no success. Do you know how I can make rows in the forest plot closer together and use the vertical space more efficiently (i.e., make the study more compact)? So you can see the issue I'm referring to, I've pasted the code for my plot before which should be reproducible if you run it in R.

Any assistance would be greatly appreciated. I think it would be quite difficult for me to make the plot in another package for my publication.


All Best,
James

###################################################################################
# install libraries
library(psych)
library(metafor)
library(meta)
library(psychometric)

# Entering in data
x1 <- c("1","2","3","4","5")
x2 <- c("Race Attitudes","Race Attitudes","Gender Identity", "Gender Identity", "Gender Identity")
x3 <- c(.342,.253,.631,.559,.563)
x4 <- c(101,98,98,90,88)
x5 <- c(1,28,1,27,440)
meta.dat <- data.frame(cbind(x1,x2,x3,x4,x5))
meta.dat

# Giving names to variables
names(meta.dat) <- c("Study","domain", "r","N","time")

# Making sure that variables are either numeric or factors
meta.dat$r <- as.numeric(as.character(meta.dat$r))
meta.dat$N <- as.numeric(as.character(meta.dat$N))
meta.dat$domain <- factor(meta.dat$domain)
meta.dat$time <- as.numeric(as.character(meta.dat$time))

# Making race the comparison group
meta.dat <- within(meta.dat, domain <- relevel(domain, ref = "Race Attitudes"))

####################
# Setting up correlations for analysis
####################

# Convert correlations to z-metric
meta.dat$fisher.r <- r2z(meta.dat$r)

# Getting the variance weight for each estimate
meta.dat$var <- (1/(meta.dat$N-3))

# Getting the SE for each estimate
meta.dat$se <- sqrt(meta.dat$var)

####################
# Getting overall results in two packages
####################

# r metric
mod1.z <- metagen(fisher.r,se,data=meta.dat,sm = "ZCOR",backtransf = TRUE)
mod1.z

x <- rma(yi = meta.dat$fisher.r, vi =meta.dat$var, method = "FE")
summary(x)
predict(x, transf=transf.ztor)

# Setting values for plots
names(meta.dat)
n <- c("101","98","98","90","88")
study <- c("1","2","3","4","5")
cont <- round(weights(x),1)
cont <- paste(cont,"%",sep = "")
domain <- c("Race Attitudes","Race Attitudes","Gender Identity", "Gender Identity", "Gender Identity")
lag <- c("< 1 day", "28 days", "< 1 day", "27 days", "440 days")

# Plotting results
forest.rma(x,
           slab=study,
           transf=transf.ztor,
           ilab=cbind(domain,n,lag,cont),
           ilab.xpos=c(-.91, -.64, -.43, -.18),
           mlab="Fixed Effects Model for All Samples",
           xlab="Pearson's r",
           showweights=FALSE,
           psize = 1,
           col="royalblue",
           level=95,
           digits=3,
           xlim=c(-1.2,1.2))

### add column headings to the plot
text(-1.22,                6.3, "Study",     pos=4,font=2)
text(-1.0,                6.3, "Domain",     pos=4,font=2)
text(-.68,                6.3, "N",     pos=4,font=4)
text(-.54,                6.3, "Lag (days)",     pos=4,font=2)
text(-.30,                6.3, "Contribution",     pos=4,font=2)
text(1.21,                  6.3, "Pearson's r [95% CI]", pos=2,font=2)
text(1.12,                  -.4, "Summary", pos=2,font=2)


	[[alternative HTML version deleted]]



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