-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA5-Meta-Analysis-BTT.Rmd
356 lines (244 loc) · 12.4 KB
/
A5-Meta-Analysis-BTT.Rmd
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
---
title: "Assignment 5 - Meta-analysis of pitch in schizophrenia"
author: "Riccardo Fusaroli"
date: "3/7/2019"
output:
md_document:
variant: markdown_github
---
# Building on the shoulders of giants: meta-analysis
## Questions to be answered
1. What is the current evidence for distinctive vocal patterns in schizophrenia? Report how many papers report quantitative estimates, comment on what percentage of the overall studies reviewed they represent (see PRISMA chart) your method to analyze them, the estimated effect size of the difference (mean effect size and standard error) and forest plots representing it. N.B. Only measures of pitch mean and pitch sd are required for the assignment. Feel free to ignore the rest (although pause behavior looks interesting, if you check my article).
```{r}
# load libraries
pacman::p_load(pacman,tidyverse,metafor,lmerTest, dplyr)
# read file into a dataframe
crazyData <- readxl::read_excel("Matrix_MetaAnalysis_Diagnosis_updated290719.xlsx")
# subsetting control data
behavedData <- crazyData %>% select("StudyID",TYPE_OF_TASK,DIAGNOSIS,SAMPLE_SIZE_HC,SAMPLE_SIZE_SZ,PITCH_F0_HC_M,PITCH_F0_HC_SD,PITCH_F0_SZ_M, PITCH_F0_SZ_SD)
# subsetting schizophrenia data
behavedDataSD <- crazyData %>% select("StudyID",TYPE_OF_TASK,DIAGNOSIS,SAMPLE_SIZE_HC,SAMPLE_SIZE_SZ,PITCH_F0SD_HC_M,PITCH_F0SD_HC_SD,PITCH_F0SD_SZ_M,PITCH_F0SD_SZ_SD)
# deleting NA's (which downsamples our dataset for metaanalysis, because studies use different measurements)
behavedData <- na.omit(behavedData)
behavedDataSD <- na.omit(behavedDataSD)
# set variables as a factor, introducing levels
behavedData <- behavedData %>%
mutate_at(c("TYPE_OF_TASK","StudyID"),as.factor)
```
```{r}
# calculating effect size for mean meassures dataframe
behavedData <- metafor::escalc("SMD",
n1i = SAMPLE_SIZE_SZ, n2i = SAMPLE_SIZE_HC,
m1i = PITCH_F0_SZ_M, m2i = PITCH_F0_HC_M,
sd1i = PITCH_F0_SZ_SD, sd2i = PITCH_F0_HC_SD,data=behavedData)
# set and examine factor levels
behavedData$TYPE_OF_TASK <- behavedData$TYPE_OF_TASK %>% as.factor()
behavedData$TYPE_OF_TASK %>% levels()
# defining a simple model predicting effect size with studies weighted by their squared standard deviation
simpleModel <- lmer(yi ~ 1 + (1|StudyID), behavedData, weights = 1/vi, REML=F,
control = lmerControl(
check.nobs.vs.nlev="ignore",
check.nobs.vs.nRE="ignore"))
# defining a model predicting effect size from type of task with studies weighted by their squared standard deviation
intermediateModel <- lmer(yi ~ 1 + TYPE_OF_TASK + (1|StudyID), behavedData, weights = 1/vi, REML=F,
control = lmerControl(
check.nobs.vs.nlev="ignore",
check.nobs.vs.nRE="ignore"))
# summarize statistical analysis of healthy controls
summary(simpleModel)
summary(intermediateModel)
# defining a model using the rma (regression meta analysis) function that fits the meta-analytic models via linear mixed effects models
metaModel <- rma(yi, vi, data = behavedData, slab=StudyID)
#adding fixed effects
metaFixedModel <- rma(yi, vi, data = behavedData,mods = cbind(TYPE_OF_TASK), slab=StudyID,weighted=T)
# summarize models
summary(metaModel)
summary(metaFixedModel)
# creating forest plots to visualize the standardized mean difference of the studies in the meta analysis
forest(metaModel, main = "Mean Model")
forest(metaFixedModel, main="Mean Model with Fixed Effect = Task")
```
```{r}
# calculating effect size for standard deviation
behavedDataSD <- metafor::escalc("SMD",
n1i = SAMPLE_SIZE_SZ, n2i = SAMPLE_SIZE_HC,
m1i = PITCH_F0SD_SZ_M, m2i = PITCH_F0SD_HC_M,
sd1i = PITCH_F0SD_HC_SD, sd2i = PITCH_F0SD_SZ_SD,data=behavedDataSD)
# set and examine factor levels
behavedDataSD$TYPE_OF_TASK <- behavedDataSD$TYPE_OF_TASK %>% as.factor()
behavedDataSD$TYPE_OF_TASK %>% levels()
# defining a simple model predicting effect size with studies weighted by their squared standard deviation
simpleModelSD <- lmer(yi ~ 1 + (1|StudyID), behavedDataSD, weights = 1/vi, REML=F,
control = lmerControl(
check.nobs.vs.nlev="ignore",
check.nobs.vs.nRE="ignore"))
# defining a model predicting effect size from type of task with studies weighted by their squared standard deviation
intermediateModelSD <- lmer(yi ~ 1 + TYPE_OF_TASK + (1|StudyID), behavedDataSD, weights = 1/vi, REML=F,
control = lmerControl(
check.nobs.vs.nlev="ignore",
check.nobs.vs.nRE="ignore"))
# summarize statistical analysis of healthy controls
summary(simpleModelSD)
summary(intermediateModelSD)
# defining a model using the regression meta analysis function
metaModelSD <- rma(yi, vi, data = behavedDataSD, slab=StudyID)
#adding Fixed effects
metaFixedModelSD <- rma(yi, vi, data = behavedDataSD,mods = cbind(TYPE_OF_TASK), slab=StudyID,weighted=T)
# summarize models
summary(metaModelSD)
summary(metaFixedModelSD)
# creating a forest plot to visualize the standardized mean difference of the studies in the meta analysis
forest(metaModelSD, main = "SD Model")
forest(metaFixedModelSD, main = "SD Model, Fixed effect = Task")
```
2. Do the results match your own analysis from Assignment 3? If you add your results to the meta-analysis, do the estimated effect sizes change? Report the new estimates and the new forest plots.
```{r}
#### Create separate calculations for our own study assignment 3 ####
# Read data from previous study into data frame
ownData <- read.csv("assignment3.csv")
# Subset dataframe by selecting diagnosis, mean, sd, and subject id.
ownData <- ownData %>% select(Diagnosis, mean, sd, Subject)
# Convert Diagnosis from levels to characters
ownData$Diagnosis <- as.character(ownData$Diagnosis)
# Create a dataframe of means including our study assignment
#SZ
# create schizophrenia data frame
szData <- filter(ownData, Diagnosis == "Schizophrenia")
# calculating number of participants
szNumber <- n_distinct(szData$Subject)
# n = 59
# mean pitch and mean of mean pitch of schizophrenic participants
szMeanVec <- szData %>% group_by(Subject) %>%
summarize(mean=mean(mean))
szMeanMean <- mean(szMeanVec$mean)
# standard deviation of the mean pitch
szSDMean <- sd(szMeanVec$mean)
# HC
# create a healthy control data frame
hcData <- filter(ownData, Diagnosis == "Control")
# calculate number of participants
hcNumber <- n_distinct(hcData$Subject)
# n = 59
# find mean pitch and mean of mean pitch of healthy controls
hcMeanVec <- hcData %>% group_by(Subject) %>%
summarize(mean=mean(mean))
hcMeanMean <- mean(hcMeanVec$mean)
# standard deviation of the mean pitch
hcSDMean <- sd(hcMeanVec$mean)
# create dataframe
ourOwnData <- data.frame(StudyID = "4", TYPE_OF_TASK = "FREE", DIAGNOSIS = "SZ", SAMPLE_SIZE_HC = hcNumber, SAMPLE_SIZE_SZ = szNumber, PITCH_F0_HC_M = hcMeanMean, PITCH_F0_HC_SD = hcSDMean, PITCH_F0_SZ_M = szMeanMean, PITCH_F0_SZ_SD = szSDMean,yi=NA,vi=NA)
# binding data frame into one with previous data
mergedData <- rbind.data.frame(behavedData, ourOwnData)
# creating effectsize and measures of uncertainty
mergedData <- metafor::escalc("SMD",
n1i = SAMPLE_SIZE_SZ, n2i = SAMPLE_SIZE_HC,
m1i = PITCH_F0_SZ_M, m2i = PITCH_F0_HC_M,
sd1i = PITCH_F0_SZ_SD, sd2i = PITCH_F0_HC_SD,data=mergedData )
# create a model using effect size and an uncertainty measure
metaModelOwn <- rma(yi, vi, data = mergedData, slab=StudyID)
#adding fixed effects
metaFixedModelOwn <- rma(yi, vi, data = mergedData,cbind("TYPE_OF_TASK"),weighted=T, slab=StudyID)
#looking at models
summary(metaModelOwn)
summary(metaFixedModelOwn)
# create forest plots displaying effectsizes
forest(metaModelOwn, main= "Mean Model")
forest(metaFixedModelOwn, main = "Mean Model, Fixed effect = Task")
# create a data frame of SD's including our study assignment
#SZ
# mean pitch and mean of mean pitch of schizophrenic participants
szSDVec <- szData %>% group_by(Subject) %>%
summarize(meanSD=mean(sd))
# mean and sd of standard deviation vector
szMeanSD <- mean(szSDVec$meanSD)
szSDSD <- sd(szSDVec$meanSD)
# HC
# find mean pitch and mean of mean pitch of healthy controls
hcSDVec <- hcData %>% group_by(Subject) %>%
summarize(meanSD=mean(sd))
# mean and sd of standard deviation vector
hcMeanSD <- mean(hcSDVec$meanSD)
hcSDSD <- sd(hcSDVec$meanSD)
# create row in dataframe following earlier example
ourOwnDataSD <- data.frame(StudyID = "4", TYPE_OF_TASK = "FREE", DIAGNOSIS = "SZ", SAMPLE_SIZE_HC = hcNumber, SAMPLE_SIZE_SZ = szNumber, PITCH_F0SD_HC_M = hcMeanSD, PITCH_F0SD_HC_SD = hcSDSD, PITCH_F0SD_SZ_M = szMeanSD, PITCH_F0SD_SZ_SD = szSDSD,yi=NA,vi=NA)
# binding data frame into one with previous data
mergedDataSD <- rbind.data.frame(behavedDataSD, ourOwnDataSD)
# creating effectsize and measures of uncertainty
mergedDataSD <- metafor::escalc("SMD",
n1i = SAMPLE_SIZE_SZ, n2i = SAMPLE_SIZE_HC,
m1i = PITCH_F0SD_SZ_M, m2i = PITCH_F0SD_HC_M,
sd1i = PITCH_F0SD_HC_SD, sd2i = PITCH_F0SD_SZ_SD,data=mergedDataSD)
# create a model using effect size and an uncertainty measure
metaModelOwnSD <- rma(yi, vi, data = mergedDataSD, slab=StudyID)
#addign fixed effects
metaFixedModelOwnSD <- rma(yi, vi, data = mergedDataSD,mods = cbind(TYPE_OF_TASK), slab=StudyID,weighted=T)
# summarize models
summary(metaModelOwnSD)
summary(metaFixedModelOwnSD)
# create forest plots displaying effectsizes
forest(metaModelOwnSD, main = "SD Model")
forest(metaFixedModelOwnSD, main = "SD Model, Fixed effect = Task")
```
3. Assess the quality of the literature: report and comment on heterogeneity of the studies (tau, I2), on publication bias (funnel plot), and on influential studies.
```{r}
# create two funnel plots in order to investigate publication bias
funnel(metaModel, main = "Mean Model")
funnel(metaModelSD, main = "SD Model")
# fixed effects
funnel(metaFixedModel, main = "Mean Model, Fixed Effect = Task")
funnel(metaFixedModelSD, main = "SD Model, Fixed Effect = Task")
# testing for influential studies using influence plots
# meta model with means
influence <- influence(metaModel)
plot(influence)
# meta model with sdandard deviation
influenceSD <- influence(metaModelSD)
plot(influenceSD)
#fixed effects
influenceFixed <- influence(metaFixedModel)
plot(influenceFixed)
# meta model with sdandard deviation
influenceSDFixed <- influence(metaFixedModelSD)
plot(influenceSDFixed)
# Extra tests
# funnel
regtest(metaModel) # test for funnel plot asymmetry: z = 1.5798, p = 0.1142
regtest(metaModelSD) # test for funnel plot asymmetry: z = 0.2004, p = 0.8412
# kendall's tau
ranktest(metaModel) # k tau = 0.20, p = 0.72
ranktest(metaModelSD) # k tau = -0.28, p = 0.69
# tau 2
metaModel$tau2 # 0.071
metaModelSD$tau2 # 1.30
# calculate I square from the two meta models
metaModel$I2
# 50.29
metaModelSD$I2
# 95.37
# Extra tests
# funnel
regtest(metaFixedModel) # test for funnel plot asymmetry: z = 1.1308, p = 0.2581
regtest(metaFixedModelSD) # test for funnel plot asymmetry: z = 0.3027, p = 0.7621
# kendall's tau
ranktest(metaFixedModel) #Kendall's tau = 0.2000, p = 0.7194
ranktest(metaFixedModelSD) #Kendall's tau = -0.2762, p = 0.1686
# tau^2
metaFixedModel$tau2 # 0.09239298
metaFixedModelSD$tau2 #1.35172
# calculate I square from the two meta models
metaFixedModel$I2
# 55.33512
metaFixedModelSD$I2
# 95.56817
```
## Tips on the process to follow:
- Download the data on all published articles analyzing voice in schizophrenia and the prisma chart as reference of all articles found and reviewed
- Look through the dataset to find out which columns to use, and if there is any additional information written as comments (real world data is always messy!).
* Hint: PITCH_F0M and PITCH_F0SD group of variables are what you need
* Hint: Make sure you read the comments in the columns: `pitch_f0_variability`, `frequency`, `Title`, `ACOUST_ANA_DESCR`, `DESCRIPTION`, and frma`COMMENTS`
- Following the procedure in the slides calculate effect size and standard error of the effect size per each study. N.B. we focus on pitch mean and pitch standard deviation.
. first try using lmer (to connect to what you know of mixed effects models)
. then use rma() (to get some juicy additional statistics)
- Build a forest plot of the results (forest(model))
- Go back to Assignment 3, add your own study to the data table, and re-run meta-analysis. Do the results change?
- Now look at the output of rma() and check tau and I2