guido-s / meta

Official Git repository of R package meta
http://cran.r-project.org/web/packages/meta/index.html
GNU General Public License v2.0
82 stars 32 forks source link

Use of studlab versus variable name in forest plots affects heterogeneity stats and justification #33

Closed vjilmari closed 3 years ago

vjilmari commented 3 years ago

There seems to be a minor bug when leftcols are manually defined in forest plots. If study is not referred to as "studlab" but for example the name of the variable which was defined as "studlab" in the model, heterogeneity stats disappear and justifying the study-variable does not work. This is not a problem if one just remembers to use studlab, but once you start adding other lefcols with variable names, it is perhaps easily forgotten.

Below is an example

library(meta)

#generate some data
d<-data.frame(Est=c(.04,.07,.01,.04),
              SE=c(.01,.02,.01,.01),
              n=c(292,141,356,315),
              Study=paste0("Study",1:4))

#run generic meta-analysis
m<-metagen(TE = Est,
        seTE = SE,
        data = d,
        studlab = Study)

#default forest plot
forest(m)

#Add sample size and define leftcols with variable names (heterogeneity disappears and Study is not left-justified)
forest(m,leftcols=c("Study","n"),
       just.studlab = "left")

#Add sample size and define leftcols with studlab for Study (all fine)
forest(m,leftcols=c("studlab","n"),
       just.studlab = "left")
guido-s commented 3 years ago

Thank you for the comment.

For technical reasons, study labels must be provided as "studlab" instead of the variable name defining the study labels in the meta-analysis. I added corresponding text to the help page of the forest function.