Today’s learning objectives

  • Be able to compare treatments by aggregating results from multiple studies
  • Be able to assess possible sources of bias
  • Be able to appreciate the differences between observational studies and clinical trials in the context of meta-analyses

Curriculum

Agenda

  • [dpqr] functions in R
  • Meta-analysis basics in R
  • Math of meta-analysis
  • Interpreting and evaluating a meta-analysis
  • Questionnaire + exercises

Packages today

library(tidyverse)
library(meta)
library(medisr)

base <- "#1f77b4"

Why is R the favored tool in epidemiological/healthcare research?


  • Open source (free and no licenses = reproducible)
  • Because statisticians use it
  • Non-standard evaluation (NSE) makes code very readable
  • Important tools native to R (in base R)
    • data.frame - perfect for analyzing data
    • Formula language (an eDSL) - perfect framefork for implementing new estimators
    • The [dpqr] functions

[dpqr] functions in R

In R the probability density function, cumulative distribution function, quantile function and random variate generation for many standard probability distributions are available in the stats package. The functions are named in the form dxxx, pxxx, qxxx and rxxx respectively.


They replace statistical tables that used to be printed in books.

  [1] 0.5000000 0.5039894 0.5079783 0.5119665 0.5159534 0.5199388 0.5239222
  [8] 0.5279032 0.5318814 0.5358564 0.5398278 0.5437953 0.5477584 0.5517168
 [15] 0.5556700 0.5596177 0.5635595 0.5674949 0.5714237 0.5753454 0.5792597
 [22] 0.5831662 0.5870644 0.5909541 0.5948349 0.5987063 0.6025681 0.6064199
 [29] 0.6102612 0.6140919 0.6179114 0.6217195 0.6255158 0.6293000 0.6330717
 [36] 0.6368307 0.6405764 0.6443088 0.6480273 0.6517317 0.6554217 0.6590970
 [43] 0.6627573 0.6664022 0.6700314 0.6736448 0.6772419 0.6808225 0.6843863
 [50] 0.6879331 0.6914625 0.6949743 0.6984682 0.7019440 0.7054015 0.7088403
 [57] 0.7122603 0.7156612 0.7190427 0.7224047 0.7257469 0.7290691 0.7323711
 [64] 0.7356527 0.7389137 0.7421539 0.7453731 0.7485711 0.7517478 0.7549029
 [71] 0.7580363 0.7611479 0.7642375 0.7673049 0.7703500 0.7733726 0.7763727
 [78] 0.7793501 0.7823046 0.7852361 0.7881446 0.7910299 0.7938919 0.7967306
 [85] 0.7995458 0.8023375 0.8051055 0.8078498 0.8105703 0.8132671 0.8159399
 [92] 0.8185887 0.8212136 0.8238145 0.8263912 0.8289439 0.8314724 0.8339768
 [99] 0.8364569 0.8389129 0.8413447 0.8437524 0.8461358 0.8484950 0.8508300
[106] 0.8531409 0.8554277 0.8576903 0.8599289 0.8621434 0.8643339 0.8665005

[dpqr] functions in R

Probability density function (PDF) is a function whose value at any given sample/point in the sample space can be interpreted as providing a relative likelihood that the value of the random variable would be close to that sample.

dnorm(3, mean = 0, sd = 1)
[1] 0.004431848
dnorm(c(4,6,8,10), mean = 8, sd = 3)
[1] 0.05467002 0.10648267 0.13298076 0.10648267


The dnorm function is short for the PDF of the normal distribution:

\[f(x) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\left( -\frac{(x - \mu)^2}{2\sigma^2} \right)\]

[dpqr] functions in R

Cumulative distribution function return the probability that \(X\) will take a value less than or equal to \(x\) for a random variable.

pnorm(1.96, mean = 0, sd = 1)
[1] 0.9750021
pnorm(0)
[1] 0.5


A way to think of the random variable \(X\) and the realized version \(x\) is the r code below:

X <- expression(rnorm(1,2,1))
x <- eval(X)

[dpqr] functions in R

Quantile function the inverse of the cumulative distribution function. Gives \(x\) such that, with probability \(p\), \(X\) will not exceed \(x\).

qnorm(0.95, mean = 0, sd = 1)
[1] 1.644854
qnorm(0.975, mean = 0, sd = 1)
[1] 1.959964


The functions qnorm and pnorm reverses eachother:

pnorm(qnorm(0.75))
[1] 0.75

[dpqr] functions in R

Random variate generation function generates a \(n\) length vector of … distributed random numbers.

rnorm(3)
[1] -1.9323245 -1.0531026 -0.2848438
rnorm(n = 3, mean = 0, sd = 1)
[1] -0.8409181 -0.9764585 -0.9796313


Differnt distributions have different parameterizations (uniform distribution)

runif(n = 3, min = 2, max = 5)
[1] 2.206870 2.221249 3.941555

Random number generator (RNG) in R

For things that require randomness in R (e.g. sampling) the default is the Mersenne-Twister pseudo-random number generator (MT19937). This can be controlled through the set.seed function.

rnorm(3,0,1)
[1] 0.6013403 1.8039694 0.2958246
rnorm(3,0,1)
[1] 0.1659295 0.9404675 0.1138850
set.seed(1)
rnorm(3,0,1)
[1] -0.6264538  0.1836433 -0.8356286
rnorm(3,0,1)
[1]  1.5952808  0.3295078 -0.8204684
set.seed(1)
rnorm(3,0,1)
[1] -0.6264538  0.1836433 -0.8356286

See ?distributions for more info

Meta-analysis

The Lancet (2005) - Efficacy and safety of cholesterol-lowering treatment: prospective meta-analysis of data from 90 056 participants in 14 randomised trials of statins

The evidence pyramid!


Systematic review: Systematically searching for availablepublications/studies with the purpose of finding all relevant material

Meta-analysis: Synthesizing aggregated information from several sources

Meta-analysis in R

Meta-analysis in R

These data come from a meta-analysis comparing Nedocromil sodium with placebo for preventing exercise-induced bronchoconstriction

dataset01 <- medisr::dataset01
dataset01
# A tibble: 17 × 8
   author       year     Ne    Me    Se    Nc    Mc    Sc
   <chr>        <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
 1 Boner        1988     13  13.5 13.8     13  20.8  21.5
 2 Boner        1989     20  15.7 13.1     20  22.7  16.5
 3 Chudry       1987     12  21.3 13.1     12  39.7  12.9
 4 Comis        1993     12  14.5 12.2     12  31.3  15.1
 5 DeBenedictis 1994a    17  14.4 11.1     17  27.4  17.3
 6 DeBenedictis 1994b     8  14.8 18.6      8  31.4  20.6
 7 DeBenedictis 1995     13  15.7 16.8     13  29.6  18.9
 8 Debelic      1986     12  29.8 16.0     12  48.1  15.1
 9 Henriksen    1988     12  17.5 13.1     12  47.2  16.5
10 Konig        1987     12  12   14.6     12  26.2  12.3
11 Morton       1992     16  15.8 13.4     16  38.4  18.0
12 Novembre     1994f    24  15.4  8.35    24  28.5  13.8
13 Novembre     1994s    19  11   12.4     19  26.1  14.9
14 Oseid        1995     20  14.1  9.5     20  28.9  18  
15 Roberts      1985      9  18.9 17.7      9  38.9  18.9
16 Shaw         1985      8  10.3  7.02     8  34.4  11.0
17 Todaro       1993     13  10.1  8.9     13  23.5   4  
  • Nc, Mc and Sc the sample size, mean response and standard deviation in the control group
  • Ne, Me and Se the sample size, mean response and standard deviation in the experimental treatment group

Meta-analysis using the Meta package

library(meta)

m <- metacont(n.e = Ne, mean.e = Me, sd.e = Se, n.c = Nc, mean.c = Mc, sd.c = Sc, 
              studlab = paste(author, year), data = dataset01)
m
Number of studies: k = 17
Number of observations: o = 480 (o.e = 240, o.c = 240)

                           MD               95% CI      z  p-value
Common effect model  -15.5140 [-17.8435; -13.1845] -13.05 < 0.0001
Random effects model -15.6470 [-18.1452; -13.1488] -12.28 < 0.0001

Quantifying heterogeneity (with 95% CIs):
 tau^2 = 2.5162 [0.0000; 42.5899]; tau = 1.5862 [0.0000; 6.5261]
 I^2 = 8.9% [0.0%; 45.3%]; H = 1.05 [1.00; 1.35]

Test of heterogeneity:
     Q d.f. p-value
 17.57   16  0.3496

Details of meta-analysis methods:
- Meta-analysis comparing two groups with continuous outcomes
- Inverse variance method
- Restricted maximum-likelihood estimator for tau^2
- Q-Profile method for confidence interval of tau^2 and tau
- Calculation of I^2 based on Q
- Null hypothesis: MD = 0

Meta-analysis in text

summary(m)
                         MD               95% CI %W(common) %W(random)
Boner 1988          -7.2300 [-21.1141;   6.6541]        2.8        3.1
Boner 1989          -7.0000 [-16.2230;   2.2230]        6.4        6.6
Chudry 1987        -18.4000 [-28.8023;  -7.9977]        5.0        5.3
Comis 1993         -16.8000 [-27.7835;  -5.8165]        4.5        4.8
DeBenedictis 1994a -13.0000 [-22.7710;  -3.2290]        5.7        5.9
DeBenedictis 1994b -16.6000 [-35.8326;   2.6326]        1.5        1.6
DeBenedictis 1995  -13.9000 [-27.6461;  -0.1539]        2.9        3.1
Debelic 1986       -18.2500 [-30.6692;  -5.8308]        3.5        3.8
Henriksen 1988     -29.7000 [-41.6068; -17.7932]        3.8        4.1
Konig 1987         -14.2000 [-25.0013;  -3.3987]        4.7        4.9
Morton 1992        -22.5300 [-33.5382; -11.5218]        4.5        4.8
Novembre 1994f     -13.0400 [-19.5067;  -6.5733]       13.0       12.1
Novembre 1994s     -15.1000 [-23.8163;  -6.3837]        7.1        7.3
Oseid 1995         -14.8000 [-23.7200;  -5.8800]        6.8        7.0
Roberts 1985       -20.0000 [-36.9171;  -3.0829]        1.9        2.1
Shaw 1985          -24.1600 [-33.1791; -15.1409]        6.7        6.9
Todaro 1993        -13.4000 [-18.7042;  -8.0958]       19.3       16.5

Number of studies: k = 17
Number of observations: o = 480 (o.e = 240, o.c = 240)

                           MD               95% CI      z  p-value
Common effect model  -15.5140 [-17.8435; -13.1845] -13.05 < 0.0001
Random effects model -15.6470 [-18.1452; -13.1488] -12.28 < 0.0001

Quantifying heterogeneity (with 95% CIs):
 tau^2 = 2.5162 [0.0000; 42.5899]; tau = 1.5862 [0.0000; 6.5261]
 I^2 = 8.9% [0.0%; 45.3%]; H = 1.05 [1.00; 1.35]

Test of heterogeneity:
     Q d.f. p-value
 17.57   16  0.3496

Details of meta-analysis methods:
- Meta-analysis comparing two groups with continuous outcomes
- Inverse variance method
- Restricted maximum-likelihood estimator for tau^2
- Q-Profile method for confidence interval of tau^2 and tau
- Calculation of I^2 based on Q
- Null hypothesis: MD = 0

Functions in the Meta package

Depending on the data several functions are available in the Meta package

graph TD
    %% Custom styling to widen boxes and layout
    classDef default font-family:sans-serif,stroke-width:1px;
    classDef func font-family:monospace, color:#000;

    %% Root node
    ESD["Effect Size Data"]:::default

    %% Level 1
    ESD --> Uncalc["Uncalculated"]:::default
    ESD --> Precalc["Precalculated"]:::default

    %% Uncalculated Branch
    Uncalc --> C1["continuous"]:::default
    Uncalc --> B1["binary"]:::default

    %% continuous sub-branch
    C1 --> Mean["Mean"]:::default
    C1 --> SMD["(Standardized)<br/>Mean Difference"]:::default
    C1 --> Corr["Correlation"]:::default

    Mean --> metamean["metamean()"]:::func
    SMD --> metacont["metacont()"]:::func
    Corr --> metacor["metacor()"]:::func

    %% binary sub-branch
    B1 --> Rate["Rate"]:::default
    B1 --> Prop["Proportion"]:::default
    B1 --> IRR["Incidence<br/>Rate Ratio"]:::default
    B1 --> OR["Odds Ratio"]:::default
    B1 --> RR["Risk Ratio"]:::default

    Rate --> metarate["metarate()"]:::func
    Prop --> metaprop["metaprop()"]:::func
    IRR --> metainc["metainc()"]:::func
    OR --> metabin["metabin()"]:::func
    RR --> metabin

    %% Precalculated Branch
    Precalc --> C2["continuous"]:::default
    Precalc --> B2["binary"]:::default

    B2 --> LogT["Log-transform"]:::default

    C2 --> metagen["metagen()"]:::func
    LogT --> metagen

The functions return a meta class, several functions are availabe for it like forest or funnel

Forest plot of meta-analysis

forest(m, layout = "meta8")
png("forestplot.png", width = 2400, height = 1100, res = 200)
forest(m)
dev.off()

Subgroup analysis

dataset01 |> 
  mutate(subgroup = if_else(parse_number(year) >= 1990, "90s","80s")) |> 
  metacont(Ne,Me,Se,Nc,Mc,Sc,studlab = paste(author,year),data = _, subgroup = subgroup) |> 
  forest(layout = "meta8")

Funnel plot of meta-analysis

funnel(m)

funnel(m, type = "contour")

Your turn

  • Load the dataset01 in a new R session
library(meta)
library(medisr)
dataset01 <- medisr::dataset01
  • Use the metacont() funtion to make a meta-analysis save as model
  • Use the Class() on the model, what does this mean?
  • Use summary() on the model
  • Make a forrest plot and a funnel plot

Binary data

direct <- medisr::direct
direct
# A tibble: 17 × 14
      ID StudyID     Year_Published No_randomised15 Responders15 No_randomised16
   <dbl> <chr>       <chr>                    <dbl>        <dbl>           <dbl>
 1    61 CAGO178A23… unpublished                168           91             166
 2    67 CL3-20098-… 2001                       138           74             137
 3   135 Detke2004 … 2004                        86           63              93
 4   141 Dimidjian2… 2006                       100           25              53
 5   149 Edwards198… 1989                        21            7              21
 6   194 Goldstein2… 2004                        89           38              90
 7   198 Goldstein2… 2004                        87           34              89
 8   206 Griebel201… 2012                        80           54              79
 9   228 Higuchi2009 2009                       148           78             146
10   267 Keller2006… 2006                       154           NA             155
11   269 Keller2006… 2006                       143           NA             145
12   271 Keller2006… 2006                       164          105             161
13   320 Loo2002 (C… 2002                       147           81             139
14   378 NKD20006 (… unpublished                125           57             125
15   408 Perahia200… 2006                        97           59              99
16   422 Rapaport20… 2009                       177          100             180
17   504 Trivedi200… 2004                       154           91             149
# ℹ 8 more variables: Responders16 <dbl>, RD <dbl>, se_RD <dbl>, RR <dbl>,
#   logRR <dbl>, se_logRR <dbl>, drug15_str <chr>, drug16_str <chr>

Forest plots binary

The math of meta-analysis

Based on (Schwarzer et al. 2015)

Mean diffrence and variance

For study \(k\), the estimated mean difference between control \(c\) and experimental \(e\) is: \[\hat{\mu}_k = \hat{\mu}_{ek} - \hat{\mu}_{ck}\]

the variance of this difference is given by: \[\widehat{\text{Var}}(\hat{\mu}_k) = \frac{s_{ek}^2}{n_{ek}} + \frac{s_{ck}^2}{n_{ck}}\] and by this a confidence interval is given by:

\[\hat{\mu}_k \pm z_{1-\frac{\alpha}{2}} \sqrt{\frac{s_{ek}^2}{n_{ek}} + \frac{s_{ck}^2}{n_{ck}}}\]

print(dataset01[1,])
# A tibble: 1 × 8
  author year     Ne    Me    Se    Nc    Mc    Sc
  <chr>  <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 Boner  1988     13 13.54 13.85    13 20.77 21.46
(mu <- 13.54-20.77)
[1] -7.23
(var <- (13.85^2/13)+21.46^2/13)
[1] 50.18108
mu - qnorm(0.975) * sqrt(var)
[1] -21.11411
mu + qnorm(0.975) * sqrt(var)
[1] 6.654112
capture.output(summary(m))[2]
[1] "Boner 1988          -7.2300 [-21.1141;   6.6541]        2.8        3.1"

Fixed (common) effects model

The fixed effect model assumes that the estimated effects from the component studies in a meta-analysis come from a single homogeneous population. It is an weighted average of the study estimates.

More formally, let \(k = 1, \dots, K\) index study, \(\hat{\theta}_k\) denote the intervention effect estimate from study \(k\), and \(\theta\) denote the intervention effect in the population, which we wish to estimate. Denote by \(\hat{\sigma}_k^2\) the sample estimate of \(\operatorname{Var}(\hat{\theta}_k)\).


The fixed effect model is:

\[\hat{\theta}_k = \theta + \sigma_k \epsilon_k, \quad \epsilon_k \sim N(0, 1)\]

We now consider the fixed effect estimate of \(\theta\), denoted by \(\hat{\theta}_F\). Given estimates \((\hat{\theta}_k, \hat{\sigma}_k), k = 1, \dots, K\), the maximum-likelihood estimate under the above equation is:

\[\hat{\theta}_F = \frac{\sum_{k=1}^K \hat{\theta}_k / \hat{\sigma}_k^2}{\sum_{k=1}^K 1 / \hat{\sigma}_k^2} = \frac{\sum_{k=1}^K w_k \hat{\theta}_k}{\sum_{k=1}^K w_k}\]

Fixed (common) effects model

Accordingly, \(\hat{\theta}_F\) is a weighted average of the individual effect estimates \(\hat{\theta}_k\) with weights \(w_k = 1 / \hat{\sigma}_k^2\). Therefore, this method is called the inverse variance method.

The variance of \(\hat{\theta}_F\) is estimated by:

\[\widehat{\operatorname{Var}}(\hat{\theta}_F) = \frac{1}{\sum_{k=1}^K w_k}\]

A \((1 - \alpha)\) confidence interval for \(\hat{\theta}_F\) can be calculated by

\[\hat{\theta}_F \pm z_{1-\frac{\alpha}{2}} \text{ S.E.}(\hat{\theta}_F)\]

with standard error \(\text{S.E.}(\hat{\theta}_F) = \sqrt{\widehat{\text{Var}}(\hat{\theta}_F)}\)

The fixed effect estimate \(\hat{\theta}_F\) and its variance can be calculated using the following quantities:

\[\hat{\theta}_k = \hat{\mu}_k \qquad \hat{\sigma}^2_k = \widehat{\text{Var}}(\hat{\mu}_k)\]

Random effects model

The random effects model seeks to account for the fact that the study effect estimates \(\hat{\theta}_k\) are often more variable than assumed in the fixed effect model.

\[ \begin{align} \text{Fixed Effects:}\quad\hat{\theta}_k &= \theta + \sigma_k \epsilon_k, \quad \qquad \epsilon_k \sim N(0, 1)\\ \text{Random Effects:}\quad\hat{\theta}_k &= \theta + \sigma_k \epsilon_k + u_k, \quad \epsilon_k \sim N(0, 1)\quad u_k \sim N(0, \tau^2) \end{align} \]

The fixed effects model is a special case of the random effects model where \(\tau^2 = 0\)

To calculate the random effects model we need to calculate some metrics:

\[ Q = \sum_{k=1}^{K} w_k (\hat{\theta}_k - \hat{\theta}_F)^2 \]

The weighted sum of squares about the fixed effect estimate with \(w_k = 1/\hat{\sigma}_k^2\). This is usually referred to as either the homogeneity test statistic or the heterogeneity statistic. Next:

\[ S = \sum_{k=1}^{K} w_k - \frac{\sum_{k=1}^{K} w_k^2}{\sum_{k=1}^{K} w_k} \]

Random effects model

If \(Q < (K - 1)\), then \(\hat{\tau}^2\) is set to 0 and the random effects estimate \(\hat{\theta}_R\) is set equal to the fixed effect estimate \(\hat{\theta}_F\). Otherwise, the DerSimonian–Laird estimator of the between-study variance is defined as:

\[\hat{\tau}^2 = \frac{Q - (K - 1)}{S}\]

And the random effects estimate and its variance are similarily to fixed effects given by:

\[\hat{\theta}_R = \frac{\sum_{k=1}^{K} w_k^* \hat{\theta}_k}{\sum_{k=1}^{K} w_k^*}\qquad \widehat{\text{Var}}(\hat{\theta}_R) = \frac{1}{\sum_{k=1}^{K} w_k^*}\]

with weights:

\[w_k^* = 1/(\hat{\sigma}_k^2 + \hat{\tau}^2)\]

The random effects estimator \(\hat{\theta}_R\) is a weighted average of the individual effect estimates \(\hat{\theta}_k\) with weights \(1/(\hat{\sigma}_k^2 + \hat{\tau}^2)\). Now however \(\hat{\tau}^2\) makes the weights less favoring of the large studies.

Random effects model in R and math

\[\hat{\mu}_k = \hat{\mu}_{ek} - \hat{\mu}_{ck}\] \[\widehat{\text{Var}}(\hat{\mu}_k) = \frac{s_{ek}^2}{n_{ek}} + \frac{s_{ck}^2}{n_{ck}} \qquad \hat{\mu}_k \pm z_{1-\frac{\alpha}{2}} \sqrt{\frac{s_{ek}^2}{n_{ek}} + \frac{s_{ck}^2}{n_{ck}}}\] \[\hat{\theta}_k=\hat{\mu}_{k}\qquad \hat{\sigma}_k^2 = \widehat{\text{Var}}(\hat{\mu}_k)\] \[w_k = 1 / \hat{\sigma}_k^2\] \[\hat{\theta}_F = \frac{\sum_{k=1}^K \hat{\theta}_k / \hat{\sigma}_k^2}{\sum_{k=1}^K 1 / \hat{\sigma}_k^2} = \frac{\sum_{k=1}^K w_k \hat{\theta}_k}{\sum_{k=1}^K w_k}\qquad \widehat{\operatorname{Var}}(\hat{\theta}_F) = \frac{1}{\sum_{k=1}^K w_k}\] \[\hat{\theta}_F\pm z_{1-\frac{\alpha}{2}}S.E.(\hat{\theta}_F)\] \[Q = \sum_{k=1}^{K} w_k (\hat{\theta}_k - \hat{\theta}_F)^2 \qquad p = P(\chi^2_{K-1} \geq Q)\qquad S = \sum_{k=1}^{K} w_k - \frac{\sum_{k=1}^{K} w_k^2}{\sum_{k=1}^{K} w_k}\] \[I^2 = \frac{Q-(K-1)}{Q}\qquad \hat{\tau}^2 = \frac{Q - (K - 1)}{S}\] \[w_k^* = 1/(\hat{\sigma}_k^2 + \hat{\tau}^2)\] \[\hat{\theta}_R = \frac{\sum_{k=1}^K \hat{\theta}_k / (\hat{\sigma}_k^2+ \hat{\tau}^2)}{\sum_{k=1}^K 1 / (\hat{\sigma}_k^2+ \hat{\tau}^2)} = \frac{\sum_{k=1}^K w_k^* \hat{\theta}_k}{\sum_{k=1}^K w_k^*}\qquad \widehat{\operatorname{Var}}(\hat{\theta}_R) = \frac{1}{\sum_{k=1}^K w^*_k}\] \[\hat{\theta}_R\pm z_{1-\frac{\alpha}{2}}S.E.(\hat{\theta}_R)\]

Random and fixed effects calculated in R:

tmp <- dataset01 |> 
  mutate(
    mu         = Me - Mc,
    var        = (Se^2 / Ne) + (Sc^2 / Nc), 
    lower      = mu - qnorm(0.975) * sqrt(var),
    upper      = mu + qnorm(0.975) * sqrt(var),
    
    weight_fix = 1 / var,
    w_fix      = (weight_fix / sum(weight_fix)) * 100,
    est_fix    = sum(weight_fix * mu) / sum(weight_fix),
    var_fix    = 1 / sum(weight_fix),
    lower_fix  = est_fix - qnorm(0.975) * sqrt(var_fix),
    upper_fix  = est_fix + qnorm(0.975) * sqrt(var_fix),
    
    Q          = sum(weight_fix * (mu - est_fix)^2),
    Q_P        = pchisq(Q, df = n() - 1, lower.tail = FALSE),
    I2         = ((Q - (n() - 1)) / Q) * 100,
    S          = sum(weight_fix) - (sum(weight_fix^2) / sum(weight_fix)),
    tau2       = (Q - (n() - 1)) / S,
    
    weight_ran = 1 / (var + tau2),
    w_ran      = (weight_ran / sum(weight_ran)) * 100,
    est_ran    = sum(weight_ran * mu) / sum(weight_ran),
    var_ran    = 1 / sum(weight_ran), 
    lower_ran  = est_ran - qnorm(0.975) * sqrt(var_ran),
    upper_ran  = est_ran + qnorm(0.975) * sqrt(var_ran)
    )

Check of calculations

author mu var lower upper weight_fix w_fix est_fix var_fix lower_fix upper_fix Q Q_P I2 S tau2 weight_ran w_ran est_ran var_ran lower_ran upper_ran
Boner -7.23 50.18 -21.11 6.65 0.02 2.82 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.02 3.08 -15.64 1.62 -18.14 -13.15
Boner -7.00 22.14 -16.22 2.22 0.05 6.38 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.04 6.58 -15.64 1.62 -18.14 -13.15
Chudry -18.40 28.17 -28.80 -8.00 0.04 5.01 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.03 5.29 -15.64 1.62 -18.14 -13.15
Comis -16.80 31.40 -27.78 -5.82 0.03 4.50 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.03 4.78 -15.64 1.62 -18.14 -13.15
DeBenedictis -13.00 24.85 -22.77 -3.23 0.04 5.68 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.04 5.93 -15.64 1.62 -18.14 -13.15
DeBenedictis -16.60 96.29 -35.83 2.63 0.01 1.47 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.01 1.64 -15.64 1.62 -18.14 -13.15
DeBenedictis -13.90 49.19 -27.65 -0.15 0.02 2.87 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.02 3.13 -15.64 1.62 -18.14 -13.15
Debelic -18.25 40.15 -30.67 -5.83 0.02 3.52 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.02 3.80 -15.64 1.62 -18.14 -13.15
Henriksen -29.70 36.91 -41.61 -17.79 0.03 3.83 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.03 4.11 -15.64 1.62 -18.14 -13.15
Konig -14.20 30.37 -25.00 -3.40 0.03 4.65 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.03 4.93 -15.64 1.62 -18.14 -13.15
Morton -22.53 31.55 -33.54 -11.52 0.03 4.48 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.03 4.76 -15.64 1.62 -18.14 -13.15
Novembre -13.04 10.89 -19.51 -6.57 0.09 12.98 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.08 12.15 -15.64 1.62 -18.14 -13.15
Novembre -15.10 19.78 -23.82 -6.38 0.05 7.14 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.05 7.28 -15.64 1.62 -18.14 -13.15
Oseid -14.80 20.71 -23.72 -5.88 0.05 6.82 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.04 6.99 -15.64 1.62 -18.14 -13.15
Roberts -20.00 74.50 -36.92 -3.08 0.01 1.90 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.01 2.10 -15.64 1.62 -18.14 -13.15
Shaw -24.16 21.18 -33.18 -15.14 0.05 6.67 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.04 6.85 -15.64 1.62 -18.14 -13.15
Todaro -13.40 7.32 -18.70 -8.10 0.14 19.29 -15.51 1.41 -17.84 -13.18 17.57 0.35 8.94 0.64 2.44 0.10 16.58 -15.64 1.62 -18.14 -13.15

Ten simple rules for interpreting and evaluating a meta-analysis

Based on (Carlson et al. 2023)

Rule 1: Gather and understand prerequisite context

  • Clear rationale and defined research question.
    • Formulated using PICO (Population, Intervention/Exposure, Comparison, Outcome).
  • Reporting standards: Follows established guidelines, e.g. PRISMA 2020 (Page et al. 2021), Cochrane (Cochrane Handbook for Systematic Reviews of Interventions 2019)
  • Transparent and reproducible methodology.
  • Explicit disclosure of conflicts of interest.
  • Team should include independent experts to minimize bias.

Rule 3: Evaluate methods used for citation screening and data extraction

  • Eligibility criteria defined a priori to prevent selection bias.
    • Direct alignment with the central research question.
  • Independent, dual-reviewer screening.
    • Assessment and reporting of inter-rater reliability.
  • Data extraction process - performed independently by at least 2 reviewers to reduce extraction errors and with a clear procedure for resolving discrepancies.
  • Software transparency - Specification of dedicated software used (e.g., RevMan, R, Stata, CMA).

Rule 4: Determine the risk for inherited limitations

  • Quality of a meta-analysis depends on the quality of included studies (Garbage In, Garbage Out).
    • Are the studies trying to answer an unanswerable question?
  • Risk of bias assessment - use of validated tools appropriate to study designs (e.g., Cochrane RoB tool for RCTs).
  • Clear reporting on how missing data were handled across individual studies.

Rule 5: Assess potential for publication bias

  • Could non-publication of negative/null results overestimates treatment efficacy?
  • Assess publication bias (Funnel plot)
    • Scatter plot of study size (Y-axis) vs. effect size (X-axis).
    • Symmetrical “inverted funnel” shape suggests low publication bias, while asymmetry suggests missing studies/underrepresented findings.
  • Egger’s test used to detect funnel plot asymmetry mathematically.
  • Caution:
    • Funnel plots and Egger’s test are unreliable/underpowered when \(n < 10\) studies.
    • Visual inspection should be interpreted with caution.

Rule 6: Determine whether there is methodological or subject heterogeneity

  • Methodological Heterogeneity - assess differences in study designs, intervention doses, control conditions, or outcome metrics.
  • Subject / Clinical Heterogeneity - assess differences in patient populations, disease severity, baseline characteristics, or settings.
  • Review inclusion/exclusion criteria qualitatively.

Ask: Is it appropriate to pool these studies together?

Rule 7: Determine whether there is statistical heterogeneity

  • Visual assessment (forest plot)
    • Check overlap of confidence intervals (\(95\%\ \text{CI}\)) across individual studies, poor overlap indicates high heterogeneity.
  • Statistical tests
    • Cochran’s Q test: Low \(p\)-value (\(p < 0.10\)) indicates presence of heterogeneity.
    • \(I^2\) Statistic: Percentage of variation due to heterogeneity rather than chance.
      • \(< 25\%\): Low | \(50\%\): Moderate | \(> 75\%\): High
  • Statistical modeling
    • Fixed-Effects Model: Assumes one true effect size; appropriate only when heterogeneity is low.
    • Random-Effects Model: Accounts for between-study variance; required when heterogeneity is moderate/high.
    • Did they choose the right model?

If heterogeneity is extremely high, pooling studies may be inappropriate.

Rule 8: Appraise the statistical significance of the results

  • Interpreting the forest plot:
    • Line of no effect: Vertical line (1 for ratios like OR/RR; 0 for differences like MD).
    • Study estimates: Boxes (point estimates) with horizontal lines (\(95\%\ \text{CI}\)). Box size represents study weight.
    • Summary diamond: Bottom shape representing the pooled effect size and combined \(95\%\ \text{CI}\).
  • Determining significance - if the summary diamond crosses the vertical line of no effect, the overall finding is not statistically significant.
  • Studies should be ordered meaningfully (e.g., date, effect size) or grouped by subgroup rather than listed alphabetically.

Rule 9: Appraise the magnitude of the effect

  • Statistical vs. Clinical or Practical Significance
    • Large sample sizes increase statistical power, making small effect sizes statistically significant.
  • Absolute vs. Relative Differences
    • RR or OR can overstate impact without baseline context.
    • Consider Absolute Risk Reduction (ARR) to gauge practical relevance.
  • Evaluate whether the magnitude of effect justifies implementation in real-world practice.

Rule 10: Check for results from sensitivity and subgroup analyses

  • Subgroup analysis - evaluate effect sizes within specific patient populations or intervention types.
    • Identify specific drivers of clinical effect or heterogeneity.
  • Sensitivity analysis - tests robustness by re-running analysis after removing low-quality or outlier studies.
  • Assesses whether overall conclusions depend heavily on specific assumptions.

Key Concepts in Meta-Analysis

  • Inverse variance method: Precision-based weight means less precise studies weight less: \(w_k = 1 / \hat{\sigma}_k^2\).
  • Fixed (common) effects vs. random effects: Fixed (common) assumes one shared true effect vs. a distribution of true effects across studies. Choice depends on heterogeneity of the studies.
  • Within- vs. between-study variance: Sampling error inside studies (\(\hat \sigma_k^2\)) vs. true heterogeneity across studies (\(\tau^2\)).
  • \(\tau^2\): Estimated variance of true effect sizes across studies.
  • Cochran’s \(Q\): Chi-square test of whether observed variation exceeds chance alone.
  • \(I^2\) statistic: Percentage of total variation across studies due to heterogeneity rather than chance (\(0\%\text{–}100\%\)).

Observational vs experimental studies

Answering questionaires time

Assignments

Assignments I

  1. Load the data direct.dta available on moodle (Trials on medicine for depression, binary outcome)
direct <- medisr::direct
  1. Calculate logRR and RD (compare with already calculated in data)
  2. Calculate se_logRR and se_RD (compare with already calculated in data, formula for se_RD is not available in the online version of the book but can be found using google. In book see 3.1.2 and 3.1.3)
  3. Use metagen to make a meta-analysis based on logRR and se_logRR and make the forestplot.
  4. Interpret \(I^2\), \(tau^2\) and \(CohranesQ\), what is more fitting, random of fixed effects model?
  5. Use metabin to make a fixed effects meta-analysis based on responders and nonresponders, report estimates for RR, OR and RD, which do you prefer?

Assignments II

  1. Load dataset01 from the book Meta-analysis with R (“fake” data for exercises, continuous outcome) and use metacont to make a meta-analysis (make one for MD and one for SMD)
dataset01 <- medisr::dataset01
  1. Why do the estimates differ differ?
  2. Make funnel plot, one for RR and one for MD and interpret.

Extra

  1. Extract data from one of the forestplots in (Durko et al. 2018), e.g. Figure 3 panel A, using a LLM. Paste snippet/screenshot (windows: shift+Win+s) and ask for it to return the data in R code using tribbel format. You can additionally ask it to calculate the standard error from the confidence intervals. Remember always check if output, data and standard error calculation, is correct.
  2. Replicate meta-analysis in R, use metagen(sm = MEAN) using both a fixed and random effects model
  3. Do you agree with the choice to use random effects models?

References

Carlson, Rebecca B, Jennifer R Martin, and Robert D Beckett. 2023. “Ten Simple Rules for Interpreting and Evaluating a Meta-Analysis.” PLOS Computational Biology 19 (9): e1011461. https://doi.org/10.1371/journal.pcbi.1011461.
Cochrane Handbook for Systematic Reviews of Interventions. 2019. Wiley. https://doi.org/10.1002/9781119536604.
Durko, Andras P, Ruben L Osnabrugge, Nicolas M Van Mieghem, et al. 2018. “Annual Number of Candidates for Transcatheter Aortic Valve Implantation Per Country: Current Estimates and Future Projections.” European Heart Journal 39 (28): 2635–42. https://doi.org/10.1093/eurheartj/ehy107.
Page, Matthew J, Joanne E McKenzie, Patrick M Bossuyt, et al. 2021. “The PRISMA 2020 Statement: An Updated Guideline for Reporting Systematic Reviews.” Bmj 372. https://doi.org/10.1136/bmj.n71.
Schwarzer, Guido, James R Carpenter, and Gerta Rücker. 2015. “Meta-Analysis with Binary Outcomes.” In Meta-Analysis with r. Springer. https://doi.org/10.1007/978-3-319-21416-0.