Code Monkey home page Code Monkey logo

doing-meta-analysis-in-r's Introduction

Doing Meta-Analysis with R: A Hands-On Guide


Twitter URL Twitter URL Twitter URL Twitter URL

Welcome to the GitHub repository of "Doing Meta-Analysis with R: A Hands-On Guide".

This book serves as an accessible introduction into how meta-analyses can be conducted in R. Essential steps for meta-analysis are covered, including pooling of outcome measures, forest plots, heterogeneity diagnostics, subgroup analyses, meta-regression, methods to control for publication bias, risk of bias assessments and plotting tools.

Advanced, but highly relevant topics such as network meta-analysis, multi-/three-level meta-analyses, Bayesian meta-analysis approaches, SEM meta-analysis are also covered.

The programming and statistical background covered in the book are kept at a non-expert level. A print version of this book has been published with Chapman & Hall/CRC Press (Taylor & Francis).



Open Source Repository


The book has been built using {rmarkdown} and {bookdown}. Formulas are rendered using MathJax. All materials and source code we used to compile the guide can be found in this repository. You are free to fork, share and reuse contents. However, the repository is intended to be mainly "read-only"; PRs will generally not be considered (see section below & preface of the book for ways to contact us).



Contributing


This guide is an open source project, and we owe special thanks to our expert contributors who provided additional content in some of the sections of this guide.

Want to contribute to this guide yourself? Feel free to send Mathias ([email protected]{.email}) an E-mail and tell us about your proposed additions.



Citing the Guide


The suggested citation is:

Harrer, M., Cuijpers, P., Furukawa, T.A., & Ebert, D.D. (2021). _Doing Meta-Analysis with R: A Hands-On Guide_. Boca Raton, FL and London: Chapmann & Hall/CRC Press. ISBN 978-0-367-61007-4.

Download the reference as BibTeX or .ris.



Cite the Packages


In the guide, we present and use various R packages. The reason why all of us can use these packages for free is because experts all around the world have devoted enormous time and effort to their development, typically without pay. If you use some of the packages mentioned in this book for your own meta-analysis, we strongly encourage you to also cite them in your report.

In the guide, every time a new package is introduced, we also provide the reference through which it can be cited. It is also possible to run citation("package") to retrieve the preferred reference. Thanks!



doing-meta-analysis-in-r's People

Contributors

mathiasharrer avatar mcguinlu avatar pitmonticone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doing-meta-analysis-in-r's Issues

Error in sink(type = "output") : invalid connection - for Bayesian Meta-Analysis Model (12-bayesian-meta-analysis.Rmd line 132)

For Bayesian Meta-Analysis Model, 12-bayesian-meta-analysis.Rmd, for the chunk on line 132, when I run it in Rstudio on my Mac (R version 3.6.2),

  • it twice prompts me to install developer tools. I say no because I've Xcode loaded
  • then it throws a complicated double-error (below)

Perhaps one needs to have Rstan installed for this to work?

Compiling the C++ model
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file109b0711a3d53.cpp 2> file109b0711a3d53.cpp.err.txt' had status 1Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! clang: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' [-Wmissing-sysroot]
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:82:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/new:85:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/exception:82:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cs

Error in sink(type = "output") : invalid connection

Btw I love this guide, thanks!

Chapter 4 - Baujat plot

Dear Pr. Harrer,
First, thank you for your book which is of great help to learn meta-analysis.
I have tried to get the Baujat plot using dmetar, meta and metafor. Both metafor and meta provide almost the same plots, but it is not the case with dmetar for which the study by de Vibe seems to have a large influence, which is not the case with the two other packages.
https://bookdown.org/MathiasHarrer/Doing_Meta_Analysis_in_R/heterogeneity.html#baujat
I know that Viechtbauer use another method than Baujat (2002) but Balduzzi et al. seem to have used the method recommended by Baujat. Is it an issue or have I missed something?
For replication, here is the code that I have used :

m.gen <- metagen(TE = TE,
seTE = seTE,
studlab = Author,
data = ThirdWave,
sm = "SMD",
fixed = FALSE,
random = TRUE,
method.tau = "REML",
method.random.ci = "HK",
title = "Third Wave Psychotherapies")
meta::baujat(m.gen)
m.gen.inf <- InfluenceAnalysis(m.gen, random = TRUE)
plot(m.gen.inf, "baujat")
ma.out<-rma(yi = TE, sei = seTE, data =ThirdWave, method="REML" ,test="knha", slab=Author)
metafor::baujat(rma.out, symbol="slab")

Best,
Nicolas

cannot open Doing_Meta_Analysis_in_R.pdf

Hi. I downloaded the pdf file, but unfortunately, I cannot read it as I get an error saying that the document page tree has an issue. can you please let me know how to solve this? cheers

mtc.model error meesage

While trying to run this part of the code:

model <- mtc.model(network, 
                   linearModel = "random",
                   n.chain = 4)

The output shown is
Error in mtc.model(network, linearModel = "random", n.chain = 4, likelihood = NULL, : No appropriate likelihood could be inferred. Please specify one.

If I specify normal and identity for the likelihood and link the error changes to

Error in validate.data.normal.identity(list(study = c(1L, 1L, 2L, 2L, : all(data.ab[["std.err"]] > 0) is not TRUE

On a related note, the Willms1999 study has three entries and the placebo arm has an std.err value of 0.4002. Isn't this supposed to be NA?

P.S The data was loaded from the file load("senn2013_reshape.rda")

Error plotting CFA example with semPaths()

Hi, I've been following the examples in chapter 14.3 Confirmatory Factor Analysis_.
I run into an error while attempting to use the semPaths() function, all other outputs seem ok (note: The function works fine when I try to replicate the example from the mediation chapter 14.4.4).

Console reads:

semPaths(cfa.plot,

  •      whatLabels = "est", 
    
  •      edge.color = "black", 
    
  •      nodeLabels = labels,
    
  •      )
    

Error in if (Layout[x[1], 2] != Layout[x[2], 2]) return(0) else return(sum(Layout[Layout[, :
missing value where TRUE/FALSE needed

My semPlotModel object looks like this:

meta2semPlot(cfa2)
An object of class "semPlotModel"
Slot "Pars":
label lhs edge rhs est std group fixed par
36 Ins_Q f_Insomnia -> Quality 0.5694354 0.5694354 Group 1 FALSE 0
37 Ins_L f_Insomnia -> Latency 0.5906298 0.5906298 Group 1 FALSE 0
38 Ins_E f_Insomnia -> Efficiency 0.7604548 0.7604548 Group 1 FALSE 0
46 Las_D f_Lassitude -> DTDysf 0.6799554 0.6799554 Group 1 FALSE 0
47 Las_H f_Lassitude -> HypSomnia 0.6418422 0.6418422 Group 1 FALSE 0
50 Quality <-> Quality 0.6757433 0.6757433 Group 1 FALSE 0
58 Latency <-> Latency 0.6511564 0.6511564 Group 1 FALSE 0
66 Efficiency <-> Efficiency 0.4217085 0.4217085 Group 1 FALSE 0
74 DTDysf <-> DTDysf 0.5376606 0.5376606 Group 1 FALSE 0
82 HypSomnia <-> HypSomnia 0.5880386 0.5880386 Group 1 FALSE 0
90 f_Insomnia <-> f_Insomnia 1.0000000 1.0000000 Group 1 FALSE 0
91 f_Insomnia <-> f_Lassitude 0.3776908 0.3776908 Group 1 FALSE 0
98 f_Lassitude <-> f_Lassitude 1.0000000 1.0000000 Group 1 FALSE 0

Slot "Vars":
name manifest exogenous
1 A TRUE NA
2 C TRUE NA
3 ES TRUE NA
4 E TRUE NA
5 I TRUE NA
6 f_Insomnia FALSE NA
7 f_Lassitude FALSE NA

Slot "Thresholds":
data frame with 0 columns and 0 rows

Slot "Computed":
[1] TRUE

Slot "ObsCovs":
[[1]]
A C ES E I
A 1.00000000 0.3897191 0.4326588 0.04945629 0.09603706
C 0.38971906 1.0000000 0.4272424 0.11929317 0.19292425
ES 0.43265882 0.4272424 1.0000000 0.22690163 0.18105566
E 0.04945629 0.1192932 0.2269016 1.00000000 0.43614968
I 0.09603706 0.1929243 0.1810557 0.43614968 1.00000000

Slot "ImpCovs":
[[1]]
A C ES E I
A 1.0000000 0.3363255 0.4330299 0.1462384 0.1380413
C 0.3363255 1.0000000 0.4491473 0.1516814 0.1431793
ES 0.4330299 0.4491473 1.0000000 0.1952946 0.1843479
E 0.1462384 0.1516814 0.1952946 1.0000000 0.4364241
I 0.1380413 0.1431793 0.1843479 0.4364241 1.0000000

Slot "Original":
list()

These are my current soft & packages versions:

sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] metaSEM_1.2.5 OpenMx_2.18.1 semPlot_1.1.2

My full script:
metaCFA.txt

Typo in 12.1

The very last analysis in 12.1, where the model without level 3 is being compared to the full three-level model using anova(), reads anova(full.model, model.l2.removed) when it should read anova(full.model, model.l3.removed). As written, the code is just repeating the previous anova. [thanks for the great book!]

How to assess and correct for publication bias in three-level meta-analysis?

Dear Mathias
I was recently reading your book on meta-analysis"Doing Meta-Analysis in R: A Hands-on Guide",I used the method of three-level meta-analysis inside to complete my graduation design. One problem I encountered was that the results of the three-level meta-analysis were calculated using rma.mv in metafor, while the functions like eggers.test , trimfill in Chapter 9 Publication Bias cannot be applied to the results of rma.mv. I wonder how to correct the results of the three-level meta-analysis for publication bias. That's very important to me and hope you can help me, thank you!

Build errors

I tried to build in bs4_book format with R 4.2 and encountered two errors:

08-forestplots.Rmd

Quitting from lines 6061-6067 (Doing_Meta_Analysis_in_R.Rmd)
Error in forest.meta(m.gen, sortvar = TE, predict = TRUE, print.tau2 = FALSE, :
argument 3 matches multiple formal arguments
Calls: ... withVisible -> eval_with_user_handlers -> eval -> eval -> forest
In addition: Warning messages:
1: In pack_rows(., "Core Database", 1, 6, latex_align = "c", latex_gap_space = "2em", :
latex_align parameter is not used in HTML Mode,
use label_row_css instead.
2: In pack_rows(., "Citation Database", 7, 9, latex_align = "c", latex_gap_space = "2em", :
latex_align parameter is not used in HTML Mode,
use label_row_css instead.
3: In pack_rows(., "Dissertations", 10, 10, latex_align = "c", latex_gap_space = "2em", :
latex_align parameter is not used in HTML Mode,
use label_row_css instead.
4: In pack_rows(., "Study Registries", 11, 12, latex_align = "c", latex_gap_space = "2em", :
latex_align parameter is not used in HTML Mode,
use label_row_css instead.
5: Use argument 'fixed' instead of 'comb.fixed' (deprecated).
6: Use argument 'random' instead of 'comb.random' (deprecated).
Execution halted

Exited with status 1.

The error message says fores.meta in 08-forestplots.Rmd. However, I was able to fix the following forest function in lines97-101 by replacing predict argument with prediction.

The other error is:

Quitting from lines 11734-11735 (Doing_Meta_Analysis_in_R.Rmd)
Error in namespaceLocalSearch(model, name) :
no slot of name "penalties" for this object of class "MxModel"
Calls: ... imxExtractMethod -> namespaceSearch -> namespaceLocalSearch
In addition: There were 13 warnings (use warnings() to see them)
Execution halted

I have no solution to this error.

Typos

07-heterogeneity:
LINE 260: "form meta-analysis to meta-analysis" should be FROM.

14-netwma:
LINE 1793: The latex code lacks backslash.

Round up values for METABIN

Hi, I realized the metabin function does not round up values like risk ratio 0.905 to 0.91 in the forest plot. The risk ratio value remains 0.90 in the forest plot figure. Any possible solution to this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.