Created
August 24, 2014 07:06
-
-
Save Lakens/e6b81b7241e3019b12d3 to your computer and use it in GitHub Desktop.
Perform a meta-analysis in R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Script based on Carter & McCullough (2014) doi: 10.3389/fpsyg.2014.00823 | |
#Load Libraries | |
library(meta) | |
library(metafor) | |
#Insert effect sizes and sample sizes | |
es.d<-c(0.38,0.41,-0.14,0.63,0.22) | |
n1<-c(75,48,22,18,60) | |
n2<-c(75,52,21,20,55) | |
#Calculate Variance ES | |
es.d.v <-(((n1+n2)/(n1*n2))+(es.d^2/(2*(n1+n2)))) | |
#Calculate Standard Errors ES | |
d.se<-sqrt(es.d.v) | |
#Fixed-effect and Random-effects meta-analysis | |
#Once with meta package, once with metafor package | |
meta1<-metagen(es.d, d.se) | |
meta2<-rma(es.d, es.d.v) | |
#Show results from both packages | |
meta1 | |
meta2 | |
#Forest Plot | |
#If you add studies, make sure to match number of labels in studlab variable. | |
forest(meta1, studlab=c("Study1","Study2","Study3","Study4","Study5"), xlab="Cohen’s d", col.square="black",xlim=c(-3,3), col.diamond="black", fontsize=14, plotwidth=unit(12, "cm"), squaresize=0.5, leftcols=c("studlab"), rightcols=c("effect", "ci"), hetstat=FALSE, comb.fixed=FALSE, text.random="Overall ES", print.tau2=FALSE,print.I2=FALSE,TE.random=FALSE, seTE.random=FALSE) | |
#Outlier Analysis and Check for Influential Cases | |
influence(meta2) | |
plot(influence(meta2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment