# Meta-analysis with SMDs # FROM: https://wviechtb.github.io/metadat/reference/dat.normand1999.html library(metafor) # copy data into 'data' and examine data data <- dat.normand1999 data # using the escalc() function, calculate mean differences and corresponding sampling variances data <- escalc(measure="MD", m1i=m1i, sd1i=sd1i, n1i=n1i, m2i=m2i, sd2i=sd2i, n2i=n2i, data=data, , slab=source) data # last two columns are the calculated yi and vi values # meta-analysis of mean differences using a random-effects model result <- rma(yi, vi, data=data) result # using the escalc() function, calculate standardised mean differences (SMD) and corresponding sampling variances data <- escalc(measure="SMD", m1i=m1i, sd1i=sd1i, n1i=n1i, m2i=m2i, sd2i=sd2i, n2i=n2i, data=data, , slab=source) data # last two columns are the calculated yi and vi values # meta-analysis of mean differences using a random-effects model result <- rma(yi, vi, data=data) result # plots forest(result) funnel(result) ########################### # Meta-analysis with risk ratios # FROM: https://wviechtb.github.io/metadat/reference/dat.bcg.html # copy data into 'data' and examine data data <- dat.bcg data # using the escalc() function, calculate log risk ratios and corresponding sampling variances # same with odds ratios (OR) by changing measure to "OR") data <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=data, slab=author) data # last two columns are the calculated yi and vi values # meta-analysis of risk reatios using a random-effects model result <- rma(yi, vi, data=data) result # average risk ratio with 95% CI predict(result, transf=exp) # plots forest(result) funnel(result) ########################### # Meta-analysis with correlation coefficients # FROM: https://wviechtb.github.io/metadat/reference/dat.mcdaniel1994.html # copy data into 'data' and examine data data <- dat.mcdaniel1994 data # calculate r-to-z transformed correlations and corresponding sampling variances data <- escalc(measure="ZCOR", ri=ri, ni=ni, data=data, slab=study) # meta-analysis of the transformed correlations using a random-effects model result <- rma(yi, vi, data=data) result # plots forest(result) funnel(result) ########################### # A meta-analysis using hazard ratios and 95% confidence intervals # Data from Steurer et al. (2006) # https://www.cochranelibrary.com/cdsr/doi/10.1002/14651858.CD004270.pub2/full # Create vectors for the hazard ratios and 95% CI lower and upper limits from each study study <- c("FCG on CLL 1996", "Leporrier 2001", "Rai 2000", "Robak 2000") HR <- c(0.55, 0.92, 0.79, 1.18) lower.HR <- c(0.28, 0.79, 0.59, 0.64) upper.HR <- c(1.09, 1.08, 1.05, 2.17) data <- cbind(study, HR, lower.HR, upper.HR) data <- as.data.frame(data) data$HR=as.numeric(data$HR); data$lower.HR=as.numeric(data$lower.HR); data$upper.HR=as.numeric(data$upper.HR) # Calculate yi and vi from the HR and 95% CI values entered into the data frame created above data$yi = log(data$HR) data$vi = ((log(upper.HR) - log(lower.HR))/3.92)^2 data library(metafor) # Run meta-analysis: result <- rma.uni(yi = data$yi, vi = data$vi, slab = study) result # Generate plots based on the R object 'result' plot(result, addpred = TRUE, showweights = TRUE, header = TRUE, transf = exp, qqplot = TRUE) # or: forest and funnel plots can be generated separately: forest(result, addpred = TRUE, order = "obs", showweights = TRUE, header = TRUE, transf = exp) # ordered by observed effect sizes of included studies funnel(result) funnel(result, level = c(90, 95, 99), shade = c("white", "gray55", "gray75"), refline = 0, legend = TRUE) # contour-enhanced funnel plot # trimfill method for assessing publication bias trimfill(result) # Statistical assessment of publication bias (funnel plot asymmetry): ranktest(result) regtest(result) tes(result) # test of excess significance "tes" install.packages("numDeriv") library(numDeriv) sel <- selmodel(result, type="power") # fitting selection models (selmodel) to identify the model of # potential publication bias in a meta-analysis sel # displays the selection model test result