setwd("C:/Users/sbabirye/Desktop/SHAKIRA/R/RMarkdown")
if (!require(readxl)) install.packages('readxl')
## Loading required package: readxl
library(readxl)
PTSD <- read_excel("C:/Users/sbabirye/Desktop/SHAKIRA/Students/Mugalu/PTSD/PTSD.xlsx")
This document will help you see how to conduct meta-analysis in R.
This section of the report shows how meta analysis of a single group whose effect size was proportion is conducted in R.
Different packages that will enable us conduct meta analysis in R will be loaded. These packages include; meta, dmetar, metafor, tidyverse, and PerformanceAnalytics.
if(!require(tidyverse)) install.packages("tidyverse")
## Loading required package: tidyverse
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.0 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.1 ✔ tibble 3.1.8
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
if(!require(meta)) install.packages("meta")
## Loading required package: meta
## Loading 'meta' package (version 6.2-0).
## Type 'help(meta)' for a brief overview.
## Readers of 'Meta-Analysis with R (Use R!)' should install
## older version of 'meta' package: https://tinyurl.com/dt4y5drs
if(!require(metafor)) install.packages("metafor")
## Loading required package: metafor
## Loading required package: Matrix
##
## Attaching package: 'Matrix'
##
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
##
## Loading required package: metadat
##
## Loading the 'metafor' package (version 3.8-1). For an
## introduction to the package please type: help(metafor)
if(!require(dmetar)) install.packages("dmetar")
## Loading required package: dmetar
## Extensive documentation for the dmetar package can be found at:
## www.bookdown.org/MathiasHarrer/Doing_Meta_Analysis_in_R/
if(!require(PerformanceAnalytics)) install.packages("PerformanceAnalytics")
## Loading required package: PerformanceAnalytics
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
##
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
##
## Attaching package: 'xts'
##
## The following objects are masked from 'package:dplyr':
##
## first, last
##
##
## Attaching package: 'PerformanceAnalytics'
##
## The following object is masked from 'package:graphics':
##
## legend
library (tidyverse)
library (meta)
library (metafor)
library (dmetar)
library(PerformanceAnalytics)
Different tables and summary statistics are going to be presented for our PTSD data.
summary(PTSD)
## Study Events N
## Length:11 Min. : 5.00 Min. : 30.0
## Class :character 1st Qu.:12.50 1st Qu.: 75.0
## Mode :character Median :15.00 Median :100.0
## Mean :20.82 Mean :129.3
## 3rd Qu.:28.50 3rd Qu.:160.0
## Max. :48.00 Max. :400.0
As shown above, the minimum number of events and sample size of the studies included in our analysis is 5 and 30 respectively and the maximum is 48 and 400 respectively.
Box plots for the number of events and sample size are going to be presented.
boxplot(PTSD$Events)
boxplot(PTSD$N)
Assuming we have done all the descriptive analysis that is required of us, we can now start our meta analysis which is the entire gist of this illustration.
We are now going to run the analysis that will give us the pool proportion of people with PTSD from the studies that were included in our analysis.
The random-effects model will be employed for the analysis. The studies in the analysis are assumed to be a random sample from a universe of potential studies, and this analysis will be used to make an inference to that universe.
PTSD_2 <- metaprop(event =Events ,
n = N,
data = PTSD,
studlab = Study,
method = "GLMM",
sm = "PLOGIT",
fixed = FALSE,
random = TRUE,
hakn = TRUE,
title = "Prevalence of PTSD")
summary(PTSD_2)
## Review: Prevalence of PTSD
##
## proportion 95%-CI
## Pelcovitz, 1996 0.2162 [0.0983; 0.3821]
## Barakat, 1997 0.0900 [0.0638; 0.1224]
## Manne, 1998 0.0500 [0.0164; 0.1128]
## Fuemmeler, 2001 0.4000 [0.2266; 0.5940]
## Libov, 2002 0.1875 [0.1089; 0.2903]
## Brown, 2003 0.2353 [0.1500; 0.3397]
## Kazak, 2004 0.1300 [0.0867; 0.1847]
## Manne, 2004 0.1083 [0.0590; 0.1781]
## Kazak, 2005 0.2400 [0.1826; 0.3053]
## Landolt, 2005 0.2143 [0.1252; 0.3287]
## Glover 0.3100 [0.2213; 0.4103]
##
## Number of studies combined: k = 11
## Number of observations: o = 1422
## Number of events: e = 229
##
## proportion 95%-CI
## Random effects model 0.1755 [0.1206; 0.2483]
##
## Quantifying heterogeneity:
## tau^2 = 0.3479; tau = 0.5898; I^2 = 84.7% [74.2%; 90.9%]; H = 2.55 [1.97; 3.31]
##
## Test of heterogeneity:
## Q d.f. p-value Test
## 65.23 10 < 0.0001 Wald-type
## 70.73 10 < 0.0001 Likelihood-Ratio
##
## Details on meta-analytical method:
## - Random intercept logistic regression model
## - Maximum-likelihood estimator for tau^2
## - Random effects confidence interval based on t-distribution (df = 10)
## - Logit transformation
## - Clopper-Pearson confidence interval for individual studies
From the output given, the mean effect size is 0.1755 with a 95% confidence interval of [0.1206, 0.2483. The mean effect size in the universe of comparable studies could fall anywhere in this interval.
The Q-statistic provides a test of the null hypothesis that all studies in the analysis share a common effect size. If all studies shared the same true effect size, the expected value of Q would be equal to the degrees of freedom (the number of studies minus 1). The Q-value is 65.23 with 10 degrees of freedom and p < 0.001. Using a criterion alpha of 0.05, we can reject the null hypothesis that the true effect size is the same in all these studies.
The I-squared statistic is 84.7%, which tells us that some 84.7% of the variance in observed effects reflects variance in true effects rather than sampling error.
Tau^2, the variance of true effect sizes, is 0.3479 in logit units. Tau, the standard deviation of true effect sizes, is 0.5898 in logit units.
Next we shall show how a forest plot is generated in R.
forest.meta(PTSD_2,
sortvar = Events,
prediction = TRUE,
print.tau2 = FALSE,
leftcols = c("Study", "Events", "N"),
leftlabs = c("Author", "No Events", "Sample size"))
This is how we conduct basic meta analysis is R. Thank you :) If you have any questions, you can reach out to me on shakyrababie@gmail.com