—————– 1. Meta-analysis of proportions of patients cured by endoscopic treatment —————————

metaprop1 <- read.table(text = "
Study_ID number_ENDOS ENDOS_cured
'Bergsneider, 1999' 5 3
'Bergsneider, 2000' 10 7
'Torres-Corzo, 2006' 7 7
'Husain, 2007' 10 10
'Husain, 2007' 21 21
'Ranjan, 2014' 17 14
'Sharma, 2019' 5 0
'Aggarwal, 2020' 26 26
", header = TRUE, stringsAsFactors = FALSE)

print(metaprop1)
##             Study_ID number_ENDOS ENDOS_cured
## 1  Bergsneider, 1999            5           3
## 2  Bergsneider, 2000           10           7
## 3 Torres-Corzo, 2006            7           7
## 4       Husain, 2007           10          10
## 5       Husain, 2007           21          21
## 6       Ranjan, 2014           17          14
## 7       Sharma, 2019            5           0
## 8     Aggarwal, 2020           26          26
# Install the meta package if not already installed
if (!require(meta)) {
  install.packages("meta")
  library(meta)
}
## Loading required package: meta
## Loading required package: metadat
## Loading 'meta' package (version 7.0-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
# Assuming 'df' is your DataFrame loaded as previously shown
# Meta-analysis of proportions with study labels

# Calculate the pooled proportion using metaprop function, labeling each study by the First Author
meta_analysis1 <- metaprop(event = ENDOS_cured, n = number_ENDOS, data = metaprop1, 
                          sm = "PLO", method.tau = "DL",
                          prediction = FALSE, comb.fixed = FALSE,
                          comb.random = TRUE, studlab = metaprop1$Study_ID
                          )

# Summary of the meta-analysis
summary(meta_analysis1)
##                    proportion           95%-CI %W(random)
## Bergsneider, 1999      0.6000 [0.1466; 0.9473]       15.1
## Bergsneider, 2000      0.7000 [0.3475; 0.9333]       17.9
## Torres-Corzo, 2006     1.0000 [0.5904; 1.0000]        9.6
## Husain, 2007           1.0000 [0.6915; 1.0000]        9.7
## Husain, 2007           1.0000 [0.8389; 1.0000]        9.9
## Ranjan, 2014           0.8235 [0.5657; 0.9620]       18.5
## Sharma, 2019           0.0000 [0.0000; 0.5218]        9.5
## Aggarwal, 2020         1.0000 [0.8677; 1.0000]        9.9
## 
## Number of studies: k = 8
## Number of observations: o = 101
## Number of events: e = 88
## 
##                      proportion           95%-CI
## Random effects model     0.8305 [0.6077; 0.9394]
## 
## Quantifying heterogeneity:
##  tau^2 = 1.4578 [0.2118; 13.6229]; tau = 1.2074 [0.4602; 3.6909]
##  I^2 = 57.7% [7.2%; 80.7%]; H = 1.54 [1.04; 2.28]
## 
## Test of heterogeneity:
##      Q d.f. p-value
##  16.55    7  0.0206
## 
## Details on meta-analytical method:
## - Inverse variance method
## - DerSimonian-Laird estimator for tau^2
## - Jackson method for confidence interval of tau^2 and tau
## - Logit transformation
## - Clopper-Pearson confidence interval for individual studies
## - Continuity correction of 0.5 in studies with zero cell frequencies
# To visualize the results, you can plot a forest plot
meta::forest(meta_analysis1, layout = "JAMA")

—————– 2. Meta-analysis of proportions of patients improved by endoscopic treatment —————————

metaprop2<- read.table(text = "
Study_ID number_ENDOS ENDOS_improved
'Bergsneider, 1999' 5 5
'Bergsneider, 2000' 10 10
'Zhang, 2000' 8 8
'Anandh, 2001' 9 9
'Torres-Corzo, 2006' 7 7
'Husain, 2007' 10 10
'Husain, 2007' 21 21
'Suri, 2008' 6 6
'Goel, 2008' 22 22
'Rangel-Castilla, 2009' 4 4
'Ranjan, 2014' 17 17
'Zhenye, 2017' 21 18
'Sharma, 2019' 5 5
'Aggarwal, 2020' 26 26
", header = TRUE, stringsAsFactors = FALSE)

print(metaprop2)
##                 Study_ID number_ENDOS ENDOS_improved
## 1      Bergsneider, 1999            5              5
## 2      Bergsneider, 2000           10             10
## 3            Zhang, 2000            8              8
## 4           Anandh, 2001            9              9
## 5     Torres-Corzo, 2006            7              7
## 6           Husain, 2007           10             10
## 7           Husain, 2007           21             21
## 8             Suri, 2008            6              6
## 9             Goel, 2008           22             22
## 10 Rangel-Castilla, 2009            4              4
## 11          Ranjan, 2014           17             17
## 12          Zhenye, 2017           21             18
## 13          Sharma, 2019            5              5
## 14        Aggarwal, 2020           26             26
# Install the meta package if not already installed
if (!require(meta)) {
  install.packages("meta")
  library(meta)
}
# Assuming 'df' is your DataFrame loaded as previously shown
# Meta-analysis of proportions with study labels

# Calculate the pooled proportion using metaprop function, labeling each study by the First Author
meta_analysis2 <- metaprop(event = ENDOS_improved, n = number_ENDOS, data = metaprop2, 
                          sm = "PLO", method.tau = "DL",
                          prediction = FALSE, comb.fixed = FALSE,
                          comb.random = TRUE, studlab = metaprop2$Study_ID
                          )

# Summary of the meta-analysis
summary(meta_analysis2)
##                       proportion           95%-CI %W(random)
## Bergsneider, 1999         1.0000 [0.4782; 1.0000]        5.3
## Bergsneider, 2000         1.0000 [0.6915; 1.0000]        5.5
## Zhang, 2000               1.0000 [0.6306; 1.0000]        5.4
## Anandh, 2001              1.0000 [0.6637; 1.0000]        5.4
## Torres-Corzo, 2006        1.0000 [0.5904; 1.0000]        5.4
## Husain, 2007              1.0000 [0.6915; 1.0000]        5.5
## Husain, 2007              1.0000 [0.8389; 1.0000]        5.6
## Suri, 2008                1.0000 [0.5407; 1.0000]        5.3
## Goel, 2008                1.0000 [0.8456; 1.0000]        5.6
## Rangel-Castilla, 2009     1.0000 [0.3976; 1.0000]        5.2
## Ranjan, 2014              1.0000 [0.8049; 1.0000]        5.6
## Zhenye, 2017              0.8571 [0.6366; 0.9695]       29.5
## Sharma, 2019              1.0000 [0.4782; 1.0000]        5.3
## Aggarwal, 2020            1.0000 [0.8677; 1.0000]        5.6
## 
## Number of studies: k = 14
## Number of observations: o = 171
## Number of events: e = 168
## 
##                      proportion           95%-CI
## Random effects model     0.9350 [0.8811; 0.9654]
## 
## Quantifying heterogeneity:
##  tau^2 = 0; tau = 0; I^2 = 0.0% [0.0%; 55.0%]; H = 1.00 [1.00; 1.49]
## 
## Test of heterogeneity:
##     Q d.f. p-value
##  4.76   13  0.9800
## 
## Details on meta-analytical method:
## - Inverse variance method
## - DerSimonian-Laird estimator for tau^2
## - Logit transformation
## - Clopper-Pearson confidence interval for individual studies
## - Continuity correction of 0.5 in studies with zero cell frequencies
# To visualize the results, you can plot a forest plot
meta::forest(meta_analysis2, layout = "JAMA")

—————– 3. Meta-analysis of proportions of patients who needed VPS after endoscopic treatment —————————

data_vps <- read.table(text = "
Study_ID number_ENDOS ENDOS_VPS
'Apuzzo 1984' 1 0
'Bergsneider, 1999' 5 2
'Bergsneider, 2000' 10 3
'Zhang, 2000' 8 0
'Anandh, 2001' 9 0
'Torres-Corzo, 2006' 7 0
'Husain, 2007' 10 0
'Husain, 2007' 21 0
'Suri, 2008' 6 0
'Goel, 2008' 22 0
'Jimenez-Vazquez' 9 0
'Kumar, 2008' 1 0
'Rangel-Castilla, 2009' 4 0
'Torres-Corzo, 2010' 86 8
'Ranjan, 2014' 17 2
'Zhenye, 2017' 21 7
'Sharma, 2019' 5 0
'Kaif, 2019' 30 1
'Singh, 2019' 12 3
'Konar, 2020' 61 1
'Aggarwal, 2020' 26 3
", header = TRUE, stringsAsFactors = FALSE)

print(data_vps)
##                 Study_ID number_ENDOS ENDOS_VPS
## 1            Apuzzo 1984            1         0
## 2      Bergsneider, 1999            5         2
## 3      Bergsneider, 2000           10         3
## 4            Zhang, 2000            8         0
## 5           Anandh, 2001            9         0
## 6     Torres-Corzo, 2006            7         0
## 7           Husain, 2007           10         0
## 8           Husain, 2007           21         0
## 9             Suri, 2008            6         0
## 10            Goel, 2008           22         0
## 11       Jimenez-Vazquez            9         0
## 12           Kumar, 2008            1         0
## 13 Rangel-Castilla, 2009            4         0
## 14    Torres-Corzo, 2010           86         8
## 15          Ranjan, 2014           17         2
## 16          Zhenye, 2017           21         7
## 17          Sharma, 2019            5         0
## 18            Kaif, 2019           30         1
## 19           Singh, 2019           12         3
## 20           Konar, 2020           61         1
## 21        Aggarwal, 2020           26         3
# Install the meta package if not already installed
if (!require(meta)) {
  install.packages("meta")
  library(meta)
}
# Assuming 'df' is your DataFrame loaded as previously shown
# Meta-analysis of proportions with study labels

# Calculate the pooled proportion using metaprop function, labeling each study by the First Author
meta_analysis3 <- metaprop(event = ENDOS_VPS, n = number_ENDOS, data = data_vps, 
                          sm = "PLO", method.tau = "DL",
                          prediction = FALSE, comb.fixed = FALSE,
                          comb.random = TRUE, studlab = data_vps$Study_ID
                          )

# Summary of the meta-analysis
summary(meta_analysis3)
##                       proportion           95%-CI %W(random)
## Apuzzo 1984               0.0000 [0.0000; 0.9750]        2.0
## Bergsneider, 1999         0.4000 [0.0527; 0.8534]        5.3
## Bergsneider, 2000         0.3000 [0.0667; 0.6525]        7.7
## Zhang, 2000               0.0000 [0.0000; 0.3694]        2.5
## Anandh, 2001              0.0000 [0.0000; 0.3363]        2.5
## Torres-Corzo, 2006        0.0000 [0.0000; 0.4096]        2.5
## Husain, 2007              0.0000 [0.0000; 0.3085]        2.5
## Husain, 2007              0.0000 [0.0000; 0.1611]        2.6
## Suri, 2008                0.0000 [0.0000; 0.4593]        2.4
## Goel, 2008                0.0000 [0.0000; 0.1544]        2.6
## Jimenez-Vazquez           0.0000 [0.0000; 0.3363]        2.5
## Kumar, 2008               0.0000 [0.0000; 0.9750]        2.0
## Rangel-Castilla, 2009     0.0000 [0.0000; 0.6024]        2.4
## Torres-Corzo, 2010        0.0930 [0.0410; 0.1751]       13.6
## Ranjan, 2014              0.1176 [0.0146; 0.3644]        6.9
## Zhenye, 2017              0.3333 [0.1459; 0.5697]       11.6
## Sharma, 2019              0.0000 [0.0000; 0.5218]        2.4
## Kaif, 2019                0.0333 [0.0008; 0.1722]        4.5
## Singh, 2019               0.2500 [0.0549; 0.5719]        8.0
## Konar, 2020               0.0164 [0.0004; 0.0880]        4.6
## Aggarwal, 2020            0.1154 [0.0245; 0.3015]        8.8
## 
## Number of studies: k = 21
## Number of observations: o = 371
## Number of events: e = 30
## 
##                      proportion           95%-CI
## Random effects model     0.1196 [0.0775; 0.1802]
## 
## Quantifying heterogeneity:
##  tau^2 = 0.3035 [0.0000; 1.3545]; tau = 0.5509 [0.0000; 1.1638]
##  I^2 = 28.2% [0.0%; 57.9%]; H = 1.18 [1.00; 1.54]
## 
## Test of heterogeneity:
##      Q d.f. p-value
##  27.86   20  0.1128
## 
## Details on meta-analytical method:
## - Inverse variance method
## - DerSimonian-Laird estimator for tau^2
## - Jackson method for confidence interval of tau^2 and tau
## - Logit transformation
## - Clopper-Pearson confidence interval for individual studies
## - Continuity correction of 0.5 in studies with zero cell frequencies
# To visualize the results, you can plot a forest plot
meta::forest(meta_analysis3, layout = "JAMA")

3. Meta-analysis of proportions of patients who needed VPS after endoscopic treatment

—————– 4. Meta-analysis of proportions of mortality in patients who received endoscopic treatment —————————

data_mortality <- read.table(text = "
Study_ID number_ENDOS ENDOS_mortality
'Apuzzo 1984' 1 0
'Zhang, 2000' 8 0
'Anandh, 2001' 9 0
'Torres-Corzo, 2006' 7 0
'Husain, 2007' 10 0
'Husain, 2007' 21 0
'Suri, 2008' 6 0
'Goel, 2008' 22 0
'Kumar, 2008' 1 0
'Rangel-Castilla, 2009' 4 0
'Torres-Corzo, 2010' 86 3
'Ranjan, 2014' 17 0
'Zhenye, 2017' 21 1
'Nash, 2018' 3 0
'Sharma, 2019' 5 0
'Singh, 2019' 12 0
'Konar, 2020' 61 1
'Aggarwal, 2020' 26 0
", header = TRUE, stringsAsFactors = FALSE)

print(data_mortality)
##                 Study_ID number_ENDOS ENDOS_mortality
## 1            Apuzzo 1984            1               0
## 2            Zhang, 2000            8               0
## 3           Anandh, 2001            9               0
## 4     Torres-Corzo, 2006            7               0
## 5           Husain, 2007           10               0
## 6           Husain, 2007           21               0
## 7             Suri, 2008            6               0
## 8             Goel, 2008           22               0
## 9            Kumar, 2008            1               0
## 10 Rangel-Castilla, 2009            4               0
## 11    Torres-Corzo, 2010           86               3
## 12          Ranjan, 2014           17               0
## 13          Zhenye, 2017           21               1
## 14            Nash, 2018            3               0
## 15          Sharma, 2019            5               0
## 16           Singh, 2019           12               0
## 17           Konar, 2020           61               1
## 18        Aggarwal, 2020           26               0
# Install the meta package if not already installed
if (!require(meta)) {
  install.packages("meta")
  library(meta)
}
# Assuming 'df' is your DataFrame loaded as previously shown
# Meta-analysis of proportions with study labels

# Calculate the pooled proportion using metaprop function, labeling each study by the First Author
meta_analysis4 <- metaprop(event = ENDOS_mortality, n = number_ENDOS, data = data_mortality, 
                          sm = "PLO", method.tau = "DL",
                          prediction = FALSE, comb.fixed = FALSE,
                          comb.random = TRUE, studlab = data_mortality$Study_ID
                          )

# Summary of the meta-analysis
summary(meta_analysis4)
##                       proportion           95%-CI %W(random)
## Apuzzo 1984               0.0000 [0.0000; 0.9750]        3.2
## Zhang, 2000               0.0000 [0.0000; 0.3694]        4.0
## Anandh, 2001              0.0000 [0.0000; 0.3363]        4.1
## Torres-Corzo, 2006        0.0000 [0.0000; 0.4096]        4.0
## Husain, 2007              0.0000 [0.0000; 0.3085]        4.1
## Husain, 2007              0.0000 [0.0000; 0.1611]        4.2
## Suri, 2008                0.0000 [0.0000; 0.4593]        4.0
## Goel, 2008                0.0000 [0.0000; 0.1544]        4.2
## Kumar, 2008               0.0000 [0.0000; 0.9750]        3.2
## Rangel-Castilla, 2009     0.0000 [0.0000; 0.6024]        3.8
## Torres-Corzo, 2010        0.0349 [0.0073; 0.0986]       24.7
## Ranjan, 2014              0.0000 [0.0000; 0.1951]        4.1
## Zhenye, 2017              0.0476 [0.0012; 0.2382]        8.1
## Nash, 2018                0.0000 [0.0000; 0.7076]        3.7
## Sharma, 2019              0.0000 [0.0000; 0.5218]        3.9
## Singh, 2019               0.0000 [0.0000; 0.2646]        4.1
## Konar, 2020               0.0164 [0.0004; 0.0880]        8.4
## Aggarwal, 2020            0.0000 [0.0000; 0.1323]        4.2
## 
## Number of studies: k = 18
## Number of observations: o = 320
## Number of events: e = 5
## 
##                      proportion           95%-CI
## Random effects model     0.0449 [0.0258; 0.0769]
## 
## Quantifying heterogeneity:
##  tau^2 = 0; tau = 0; I^2 = 0.0% [0.0%; 50.0%]; H = 1.00 [1.00; 1.41]
## 
## Test of heterogeneity:
##     Q d.f. p-value
##  6.47   17  0.9894
## 
## Details on meta-analytical method:
## - Inverse variance method
## - DerSimonian-Laird estimator for tau^2
## - Logit transformation
## - Clopper-Pearson confidence interval for individual studies
## - Continuity correction of 0.5 in studies with zero cell frequencies
# To visualize the results, you can plot a forest plot
meta::forest(meta_analysis4, layout = "JAMA")

4. Meta-analysis of proportions of mortality in patients who received endoscopic treatment

—————– 5. Meta-analysis of proportions of complications in patients who received endoscopic treatment —————————

data_complic <- read.table(text = "
Study_ID number_ENDOS ENDOS_Complic
'Apuzzo 1984' 1 0
'Bergsneider, 1999' 5 1
'Bergsneider, 2000' 10 2
'Zhang, 2000' 8 0
'Anandh, 2001' 9 3
'Torres-Corzo, 2006' 7 0
'Husain, 2007' 10 0
'Husain, 2007' 21 0
'Suri, 2008' 6 0
'Goel, 2008' 22 2
'Kumar, 2008' 1 0
'Rangel-Castilla, 2009' 4 0
'Torres-Corzo, 2010' 86 8
'Ranjan, 2014' 17 2
'Zhenye, 2017' 21 8
'Nash, 2018' 3 2
'Sharma, 2019' 5 0
'Kaif, 2019' 30 3
'Singh, 2019' 12 5
'Konar, 2020' 61 3
'Aggarwal, 2020' 26 5
", header = TRUE, stringsAsFactors = FALSE)

print(data_complic)
##                 Study_ID number_ENDOS ENDOS_Complic
## 1            Apuzzo 1984            1             0
## 2      Bergsneider, 1999            5             1
## 3      Bergsneider, 2000           10             2
## 4            Zhang, 2000            8             0
## 5           Anandh, 2001            9             3
## 6     Torres-Corzo, 2006            7             0
## 7           Husain, 2007           10             0
## 8           Husain, 2007           21             0
## 9             Suri, 2008            6             0
## 10            Goel, 2008           22             2
## 11           Kumar, 2008            1             0
## 12 Rangel-Castilla, 2009            4             0
## 13    Torres-Corzo, 2010           86             8
## 14          Ranjan, 2014           17             2
## 15          Zhenye, 2017           21             8
## 16            Nash, 2018            3             2
## 17          Sharma, 2019            5             0
## 18            Kaif, 2019           30             3
## 19           Singh, 2019           12             5
## 20           Konar, 2020           61             3
## 21        Aggarwal, 2020           26             5
# Install the meta package if not already installed
if (!require(meta)) {
  install.packages("meta")
  library(meta)
}
# Assuming 'df' is your DataFrame loaded as previously shown
# Meta-analysis of proportions with study labels

# Calculate the pooled proportion using metaprop function, labeling each study by the First Author
meta_analysis5 <- metaprop(event = ENDOS_Complic, n = number_ENDOS, data = data_complic, 
                          sm = "PLO", method.tau = "DL",
                          prediction = FALSE, comb.fixed = FALSE,
                          comb.random = TRUE, studlab = data_complic$Study_ID
                          )

# Summary of the meta-analysis
summary(meta_analysis5)
##                       proportion           95%-CI %W(random)
## Apuzzo 1984               0.0000 [0.0000; 0.9750]        1.8
## Bergsneider, 1999         0.2000 [0.0051; 0.7164]        3.4
## Bergsneider, 2000         0.2000 [0.0252; 0.5561]        5.5
## Zhang, 2000               0.0000 [0.0000; 0.3694]        2.2
## Anandh, 2001              0.3333 [0.0749; 0.7007]        6.2
## Torres-Corzo, 2006        0.0000 [0.0000; 0.4096]        2.2
## Husain, 2007              0.0000 [0.0000; 0.3085]        2.2
## Husain, 2007              0.0000 [0.0000; 0.1611]        2.2
## Suri, 2008                0.0000 [0.0000; 0.4593]        2.2
## Goel, 2008                0.0909 [0.0112; 0.2916]        5.9
## Kumar, 2008               0.0000 [0.0000; 0.9750]        1.8
## Rangel-Castilla, 2009     0.0000 [0.0000; 0.6024]        2.1
## Torres-Corzo, 2010        0.0930 [0.0410; 0.1751]       10.7
## Ranjan, 2014              0.1176 [0.0146; 0.3644]        5.8
## Zhenye, 2017              0.3810 [0.1811; 0.6156]        9.5
## Nash, 2018                0.6667 [0.0943; 0.9916]        2.9
## Sharma, 2019              0.0000 [0.0000; 0.5218]        2.1
## Kaif, 2019                0.1000 [0.0211; 0.2653]        7.3
## Singh, 2019               0.4167 [0.1517; 0.7233]        7.6
## Konar, 2020               0.0492 [0.0103; 0.1371]        7.5
## Aggarwal, 2020            0.1923 [0.0655; 0.3935]        8.8
## 
## Number of studies: k = 21
## Number of observations: o = 365
## Number of events: e = 44
## 
##                      proportion           95%-CI
## Random effects model     0.1558 [0.1047; 0.2257]
## 
## Quantifying heterogeneity:
##  tau^2 = 0.3686 [0.0000; 1.3087]; tau = 0.6071 [0.0000; 1.1440]
##  I^2 = 38.4% [0.0%; 63.5%]; H = 1.27 [1.00; 1.66]
## 
## Test of heterogeneity:
##      Q d.f. p-value
##  32.47   20  0.0385
## 
## Details on meta-analytical method:
## - Inverse variance method
## - DerSimonian-Laird estimator for tau^2
## - Jackson method for confidence interval of tau^2 and tau
## - Logit transformation
## - Clopper-Pearson confidence interval for individual studies
## - Continuity correction of 0.5 in studies with zero cell frequencies
# To visualize the results, you can plot a forest plot
meta::forest(meta_analysis5, layout = "JAMA")

5. Meta-analysis of proportions of complications in patients who received endoscopic treatment

—————– 6. Meta-analysis of odds ratios of the risk of use of VPS in endoscopic vs open surgery —————————

or_endo_surg <- read.table(text = "
Study_ID number_ENDOS ENDOS_VPS number_surgical Surgical_VPS
'Apuzzo 1984' 1 0 29 7
'Kumar, 2008' 1 0 9 4
'Rangel-Castilla, 2009' 4 0 6 2
", header = TRUE, stringsAsFactors = FALSE)

print(or_endo_surg)
##                Study_ID number_ENDOS ENDOS_VPS number_surgical Surgical_VPS
## 1           Apuzzo 1984            1         0              29            7
## 2           Kumar, 2008            1         0               9            4
## 3 Rangel-Castilla, 2009            4         0               6            2
# Load the necessary library
library(meta)

# Assuming mrs_odds is already loaded with your data
# You might need to check the names of your columns with names(mrs_odds)

# Meta-analysis of odds ratios
meta_analysis6 <- metabin(
  event.e = or_endo_surg$ENDOS_VPS, 
  n.e = or_endo_surg$number_ENDOS, 
  event.c = or_endo_surg$Surgical_VPS, 
  n.c = or_endo_surg$number_surgical, 
  data = or_endo_surg,
  studlab = paste(or_endo_surg$Study_ID),
  sm = "OR",                     # Specify summary measure as Odds Ratio
  method.tau = "DL",             # DerSimonian-Laird estimator for tau^2
  comb.fixed = FALSE,            # Random effects model
  comb.random = TRUE,            # Include random effects
  prediction = FALSE             # No prediction interval by default
)

# Summary of the meta-analysis
summary(meta_analysis6)
##                           OR            95%-CI %W(random)
## Apuzzo 1984           1.0000 [0.0367; 27.2642]       34.2
## Kumar, 2008           0.4074 [0.0131; 12.6365]       31.7
## Rangel-Castilla, 2009 0.2000 [0.0073;  5.4528]       34.2
## 
## Number of studies: k = 3
## Number of observations: o = 50 (o.e = 6, o.c = 44)
## Number of events: e = 13
## 
##                          OR           95%-CI     z p-value
## Random effects model 0.4342 [0.0629; 2.9985] -0.85  0.3975
## 
## Quantifying heterogeneity:
##  tau^2 = 0; tau = 0; I^2 = 0.0% [0.0%; 89.6%]; H = 1.00 [1.00; 3.10]
## 
## Test of heterogeneity:
##     Q d.f. p-value
##  0.46    2  0.7948
## 
## Details on meta-analytical method:
## - Inverse variance method
## - DerSimonian-Laird estimator for tau^2
## - Mantel-Haenszel estimator used in calculation of Q and tau^2 (like RevMan 5)
## - Continuity correction of 0.5 in studies with zero cell frequencies
# To visualize the results, you can plot a forest plot
meta::forest(meta_analysis6, layout = "JAMA")

6. Meta-analysis of odds ratios of the risk of use of VPS in endoscopic vs open surgery

—————– 7. Meta-analysis of odds ratios of the risk of use of VPS in endoscopic vs medical treatment —————————

or_endo_med <- read.table(text = "
Study_ID number_ENDOS ENDOS_VPS number_med Med_VPS
'Kumar, 2008' 1 0 1 1
'Rangel-Castilla, 2009' 4 0 1 1
", header = TRUE, stringsAsFactors = FALSE)

print(or_endo_med)
##                Study_ID number_ENDOS ENDOS_VPS number_med Med_VPS
## 1           Kumar, 2008            1         0          1       1
## 2 Rangel-Castilla, 2009            4         0          1       1
# Load the necessary library
library(meta)

# Assuming mrs_odds is already loaded with your data
# You might need to check the names of your columns with names(mrs_odds)

# Meta-analysis of odds ratios
meta_analysis7 <- metabin(
  event.e = or_endo_med$ENDOS_VPS, 
  n.e = or_endo_med$number_ENDOS, 
  event.c = or_endo_med$Med_VPS, 
  n.c = or_endo_med$number_med, 
  data = or_endo_med,
  studlab = paste(or_endo_med$Study_ID),
  sm = "OR",                     # Specify summary measure as Odds Ratio
  method.tau = "DL",             # DerSimonian-Laird estimator for tau^2
  comb.fixed = FALSE,            # Random effects model
  comb.random = TRUE,            # Include random effects
  prediction = FALSE             # No prediction interval by default
)

# Summary of the meta-analysis
summary(meta_analysis7)
##                           OR            95%-CI %W(random)
## Kumar, 2008           0.1111 [0.0012; 10.2689]       47.8
## Rangel-Castilla, 2009 0.0370 [0.0005;  2.8230]       52.2
## 
## Number of studies: k = 2
## Number of observations: o = 7 (o.e = 5, o.c = 2)
## Number of events: e = 2
## 
##                          OR           95%-CI     z p-value
## Random effects model 0.0626 [0.0027; 1.4331] -1.73  0.0828
## 
## Quantifying heterogeneity:
##  tau^2 = 0; tau = 0; I^2 = 0.0%; H = 1.00
## 
## Test of heterogeneity:
##     Q d.f. p-value
##  0.12    1  0.7308
## 
## Details on meta-analytical method:
## - Inverse variance method
## - DerSimonian-Laird estimator for tau^2
## - Mantel-Haenszel estimator used in calculation of Q and tau^2 (like RevMan 5)
## - Continuity correction of 0.5 in studies with zero cell frequencies
# To visualize the results, you can plot a forest plot
meta::forest(meta_analysis7, layout = "JAMA")