-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathmeta-tutorial.Rmd
More file actions
291 lines (230 loc) · 7.21 KB
/
Copy pathmeta-tutorial.Rmd
File metadata and controls
291 lines (230 loc) · 7.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
---
title: "How to perform a meta-analysis with R: a practical tutorial"
author: "Sara Balduzzi, Gerta Rücker, Guido Schwarzer"
output:
rmarkdown::pdf_document:
number_sections: false
rmarkdown::html_vignette:
toc: false
number_sections: false
bibliography: references.bib
vignette: >
%\VignetteIndexEntry{meta: How to perform a meta-analysis with R: a practical tutorial}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
message = TRUE,
warning = FALSE
)
options(knitr.kable.NA = ".")
load("mmiss_limit.rda")
```
This vignette provides up-to-date commands for the analyses in "How to
perform a meta-analysis with R: a practical tutorial", *Evid Based
Ment Health* [@Bald:Ruec:Schw:how:2019].
## Install R packages
```{r, eval = FALSE}
install.packages(c("meta", "metasens"))
```
## Make R packages available
```{r}
library(meta)
```
```{r, eval = FALSE}
library(metasens)
```
Note, a similar message would be printed for R package
**metasens**. However, this vignette does not actually load
**metasens** as it might not be installed in addition to **meta**.
## Default settings for R session
Print results with two significant digits and use Paule-Mandel
estimator for between-study variance.
```{r}
settings.meta(digits = 2, method.tau = "PM")
```
Note, in the publication, argument 'method.tau' was used in R function
*metabin()*. Here, we set the Paule-Mandel method as the default for
any meta-analysis conducted in the current R session.
## Import the dataset
```{r}
joy = read.csv("Joy2006.txt")
# Add new variable: miss
joy$miss = ifelse((joy$drop.h + joy$drop.p) == 0,
"Without missing data", "With missing data")
head(joy)
str(joy)
```
## Section 'Fixed effect and random effects meta-analysis'
```{r}
m.publ = metabin(resp.h, resp.h + fail.h, resp.p, resp.p + fail.p,
data = joy, studlab = paste0(author, " (", year, ")"),
label.e = "Haloperidol", label.c = "Placebo",
label.left = "Favours placebo", label.right = "Favours haloperidol")
```
Print results of meta-analysis (Figure 1).
```{r}
summary(m.publ)
```
Same printout (result not shown)
```{r, eval = FALSE}
print(summary(m.publ))
```
Create Figure 2 (file 'figure2.pdf').
```{r}
forest(m.publ, sortvar = year, prediction = TRUE,
digits.pval.Q = 3,
file = "figure2.pdf", width = 10)
```
```{r, echo = FALSE, out.width = "95%"}
knitr::include_graphics("figure2.pdf")
```
## Section 'Assessing the impact of missing outcome data'
### Subgroup analysis of studies with and without missing data
```{r}
m.publ.sub = update(m.publ, subgroup = miss, print.subgroup.name = FALSE)
m.publ.sub
```
Create Figure 3 (file 'figure3.pdf').
```{r}
forest(m.publ.sub, sortvar = year,
xlim = c(0.1, 100), at = c(0.1, 0.3, 1, 3, 10, 30, 100),
digits.pval.Q = 3, test.subgroup.common = FALSE,
label.test.subgroup.random = "Test for subgroup differences:",
file = "figure3.pdf", width = 10)
```
```{r, echo = FALSE, out.width = "95%"}
knitr::include_graphics("figure3.pdf")
```
### Use imputation methods
```{r, eval = FALSE}
# Impute as no events (ICA-0) - default
mmiss.0 = metamiss(m.publ, drop.h, drop.p)
# Impute as events (ICA-1)
mmiss.1 = metamiss(m.publ, drop.h, drop.p, method = "1")
# Observed risk in control group (ICA-pc)
mmiss.pc = metamiss(m.publ, drop.h, drop.p, method = "pc")
# Observed risk in experimental group (ICA-pe)
mmiss.pe = metamiss(m.publ, drop.h, drop.p, method = "pe")
# Observed group-specific risks (ICA-p)
mmiss.p = metamiss(m.publ, drop.h, drop.p, method = "p")
# Best-case scenario (ICA-b)
mmiss.b = metamiss(m.publ, drop.h, drop.p, method = "b", small.values = "bad")
# Worst-case scenario (ICA-w)
mmiss.w = metamiss(m.publ, drop.h, drop.p, method = "w", small.values = "bad")
# Gamble-Hollis method
mmiss.gh = metamiss(m.publ, drop.h, drop.p, method = "GH")
# IMOR.e = 2 and IMOR.c = 2 (same as available case analysis)
mmiss.imor2 = metamiss(m.publ, drop.h, drop.p, method = "IMOR", IMOR.e = 2)
# IMOR.e = 0.5 and IMOR.c = 0.5
mmiss.imor0.5 = metamiss(m.publ, drop.h, drop.p, method = "IMOR", IMOR.e = 0.5)
```
Summarise results using R function *metabind()*.
```{r}
meths = c("Available case analysis (ACA)",
"Impute no events (ICA-0)", "Impute events (ICA-1)",
"Observed risk in control group (ICA-pc)",
"Observed risk in experimental group (ICA-pe)",
"Observed group-specific risks (ICA-p)",
"Best-case scenario (ICA-b)", "Worst-case scenario (ICA-w)",
"Gamble-Hollis analysis",
"IMOR.e = 2, IMOR.c = 2", "IMOR.e = 0.5, IMOR.c = 0.5")
# Use inverse-variance method for pooling (which is used for
# imputation methods)
m.publ.iv = update(m.publ, method = "Inverse")
# Combine results (random effects)
mbr = metabind(m.publ.iv,
mmiss.0, mmiss.1,
mmiss.pc, mmiss.pe, mmiss.p,
mmiss.b, mmiss.w, mmiss.gh,
mmiss.imor2, mmiss.imor0.5,
name = meths, pooled = "random")
```
Create Figure 4 (file 'figure4.pdf').
```{r}
forest(mbr, xlim = c(0.5, 4),
leftcols = c("studlab", "I2", "tau2", "Q", "pval.Q"),
leftlab = c("Meta-Analysis Method", "I2", "Tau2", "Q", "P-value"),
type = "diamond",
digits.addcols = c(4, 2, 2, 2), just.addcols = "right",
file = "figure4.pdf", width = 10)
```
```{r, echo = FALSE, out.width = "95%"}
knitr::include_graphics("figure4.pdf")
```
## Section 'Assessing and accounting for small-study effects'
### Funnel plot
```{r, eval = FALSE}
funnel(m.publ)
```
### Harbord's score test for funnel plot asymmetry
```{r}
metabias(m.publ, method.bias = "score")
```
### Trim-and-fill method
```{r}
tf.publ = trimfill(m.publ)
tf.publ
```
```{r}
summary(tf.publ)
```
```{r, eval = FALSE}
funnel(tf.publ)
```
### Limit meta-analysis
```{r, eval = FALSE}
l1.publ = limitmeta(m.publ)
```
Note, the printout for the limit meta-analysis is not shown in this
vignette as the installation of R package **metasens** is optional.
```{r, eval = FALSE}
l1.publ
```
Create Figure 5 (file 'figure5.pdf').
```{r, eval = FALSE}
pdf("figure5.pdf", width = 10, height = 10)
#
par(mfrow = c(2, 2), pty = "s",
oma = c(0, 0, 0, 0), mar = c(4.1, 3.1, 2.1, 1.1))
#
funnel(m.publ, xlim = c(0.05, 50), axes = FALSE)
axis(1, at = c(0.1, 0.2, 0.5, 1, 2, 5, 10, 50))
axis(2, at = c(0, 0.5, 1, 1.5))
box()
title(main = "Panel A: Funnel plot", adj = 0)
#
funnel(m.publ, xlim = c(0.05, 50), axes = FALSE,
contour.levels = c(0.9, 0.95, 0.99),
col.contour = c("darkgray", "gray", "lightgray"))
legend("topright",
c("p < 1%", "1% < p < 5%", "5% < p < 10%", "p > 10%"),
fill = c("lightgray", "gray", "darkgray", "white"),
border = "white", bg = "white")
axis(1, at = c(0.1, 0.2, 0.5, 1, 2, 5, 10, 50))
axis(2, at = c(0, 0.5, 1, 1.5))
box()
title(main = "Panel B: Contour-enhanced funnel plot", adj = 0)
#
funnel(tf.publ, xlim = c(0.05, 50), axes = FALSE)
axis(1, at = c(0.1, 0.2, 0.5, 1, 2, 5, 10, 50))
axis(2, at = c(0, 0.5, 1, 1.5))
box()
title(main = "Panel C: Trim-and-fill method", adj = 0)
#
funnel(l1.publ, xlim = c(0.05, 50), axes = FALSE,
col.line = 8, lwd.line = 3)
axis(1, at = c(0.1, 0.2, 0.5, 1, 2, 5, 10, 50))
axis(2, at = c(0, 0.5, 1, 1.5))
box()
title(main = "Panel D: Limit meta-analysis", adj = 0)
#
dev.off()
```
```{r, echo = FALSE, out.width = "95%"}
knitr::include_graphics("figure5.pdf")
```
# References