Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
When conducting meta-analysis, you most likely have to calculate or convert effects sizes into an effect size with common measure. There are various tools to do this – one easy to use tool is the Practical Meta-Analysis Effect Size Calculator from David B. Wilson.
This online-tool is now implemented as an R-package: esc: Effect Size Computation for Meta Analysis.
Calculating Effect Sizes
The package covers most of the effect size calculation and conversion options from the online-tool, but in a more compact way, which gives you a better overiew. For instance, getting an effect size from a t-test, means you have to find and choose from four different options in the online tool, while the esc-package just needs one function:
esc_t(t, p, totaln, grp1n, grp2n, es.type = c("d", "g", "or", "logit", "r", "cox.or", "cox.log"), study = NULL, ...)
You can then compute the effect size, depending on your available parameters, like this:
# unequal sample size esc_t(t = 3.3, grp1n = 100, grp2n = 150) # equal sample size esc_t(t = 3.3, totaln = 200) # unequal sample size, with p-value esc_t(p = 0.03, grp1n = 100, grp2n = 150) # equal sample size, with p-value esc_t(p = 0.03, totaln = 200)
Converting Effect Sizes
The package offers various functions to convert one effect size into another: esc_d2logit()
(std. mean diff. to log-odds), esc_d2or()
(std. mean diff. to odds ratios), esc_d2r()
(std. mean diff. to correlation r), esc_or2d()
(odds ratio to std. mean diff.), esc_r2z()
(correlation coefficient r into Fisher’s z) and esc_z2r()
(Fisher’s z into correlation coefficient r). However, the es.type
-argument in each function gives you the required effect size measure directly.
Workflow with the metafor-package
The results of the effect size calculation functions in this package are returned as list with a esc
-class attribute. The combine_esc()
-function takes one or more of these esc-objects and combines them into a data.frame
that can be used as argument for further use, for instance with the rma()
-function.
e1 <- esc_2x2(grp1yes = 30, grp1no = 50, grp2yes = 40, grp2no = 45, study = "Study 1") e2 <- esc_2x2(grp1yes = 30, grp1no = 50, grp2yes = 40, grp2no = 45, es.type = "or", study = "Study 2") e3 <- esc_t(p = 0.03, grp1n = 100, grp2n = 150, study = "Study 3") e4 <- esc_mean_sd(grp1m = 7, grp1sd = 2, grp1n = 50, grp2m = 9, grp2sd = 3, grp2n = 60, es.type = "logit", study = "Study 4") mydat <- combine_esc(e1, e2, e3, e4)
Now, mydat contains a data frame with the results of several effect size calculations:
> mydat study es weight sample.size se var ci.lo ci.hi measure 1 Study 1 -0.3930426 9.944751 165 0.3171050 0.10055556 -1.01455689 0.2284717 logit 2 Study 2 0.6750000 9.944751 165 0.3171050 0.10055556 0.36256305 1.2566780 or 3 Study 3 0.2817789 59.433720 250 0.1297130 0.01682547 0.02754605 0.5360117 d 4 Study 4 -1.3981827 7.721145 110 0.3598812 0.12951447 -2.10353685 -0.6928285 logit
The meta-analysis is then computed like this (note that the different effect-size measures are just for demonstration purposes – usually, you should have only one common effect size that goes into the meta-analysis):
metafor::rma(yi = es, sei = se, method = "REML", data = mydat)
Last words
The package update 0.2.0 includes a small convenient function, write_esc()
, to write an Excel-csv-file with the converted effect sizes.
Tagged: effect-size, meta-analysis, R, rstats
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.