-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path3b-Descriptives of analyses.R
More file actions
250 lines (187 loc) · 9.56 KB
/
Copy path3b-Descriptives of analyses.R
File metadata and controls
250 lines (187 loc) · 9.56 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
library(tidyr)
library(dplyr)
load(file="dataFiles/res.wide.red.RData")
# ---------------------------------------------------------------------
# Get correlation between estimators within and across all conditions
getCor <- function(x) {
x2 <- x %>% select(id, method, b0_estimate) %>% spread(method, b0_estimate) %>% select(-id)
x3 <- cor(x2, use="p", method="spearman") %>% as.data.frame()
x3$method1 <- rownames(x3)
x4 <- gather(x3, method2, COR, -method1)
return(x4)
}
# get correlation of estimators within all conditions
res <- data.frame()
for (cond in 1:432) {
print(cond)
x <- res.wide.red %>% filter(condition==cond)
C <- getCor(x)
res <- rbind(res, data.frame(
x[1, 1:8],
C
))
}
res2 <- res %>% filter(method1=="pcurve", method2=="puniform")
summary(res2$COR)
x2 <- res.wide.red %>% filter(condition==84) %>% select(id, method, b0_estimate) %>% spread(method, b0_estimate) %>% select(-id)
plot(x2$pcurve, x2$puniform)
# get correlation of estimators across all conditions
C2 <- getCor(res.wide.red)
C2
C2 %>% filter(method1=="pcurve", method2=="puniform")
## ======================================================================
## Percentage of WAAP vs. WLS in the conditional estimator
## ======================================================================
estimator_types_desc <- res.wide.red %>%
filter(method %in% c("WAAP-WLS", "PETPEESE.lm")) %>%
select(id, condition, k, k.label, delta, delta.label, qrpEnv, qrp.label, censor, censor.label, tau, tau.label, estimator_type) %>%
group_by(condition, k, k.label, delta, delta.label, qrpEnv, qrp.label, censor, censor.label, tau, tau.label) %>%
summarise(
WAAP_perc = sum(estimator_type == "WAAP") / sum(estimator_type %in% c("WAAP", "WLS")),
WLS_perc = sum(estimator_type == "WLS") / sum(estimator_type %in% c("WAAP", "WLS")),
PET_perc = sum(estimator_type == "PET") / sum(estimator_type %in% c("PET", "PEESE")),
PEESE_perc = sum(estimator_type == "PEESE") / sum(estimator_type %in% c("PET", "PEESE"))
)
print(estimator_types_desc, n=432)
print(estimator_types_desc %>% arrange(WAAP_perc), n=432)
mean(estimator_types_desc$WAAP_perc)
mean(estimator_types_desc$WLS_perc)
# plot WAAP-WLS percentages as small multiples
# reshape to long format
WAAP_desc.long <- melt(estimator_types_desc %>% select(-PET_perc, -PEESE_perc),
id.vars=c("condition", "k", "k.label", "delta", "delta.label", "qrpEnv", "qrp.label", "censor", "censor.label", "tau", "tau.label"),
variable.name = "estimator_type", value.name = "percentage")
library(ggplot2)
ggplot(WAAP_desc.long, aes(x=k.label, y=percentage, fill=estimator_type)) + geom_bar(stat="identity") + facet_grid(qrp.label~censor.label~tau.label~delta.label)
# zoom into the mixed delta=0.2 conditions:
ggplot(WAAP_desc.long %>% filter(delta == 0.2), aes(x=k.label, y=percentage, fill=estimator_type)) + geom_bar(stat="identity") + facet_grid(tau.label~qrp.label~censor.label)
## ======================================================================
## Percentage of p-uniform return codes
# comment codes:
# 0 = regular converged estimate
# 1 = "No significant studies on the specified side"
# 2 = "set to zero if avg. p-value > .025"
## ======================================================================
puniform_comments <- res.wide.red %>%
filter(method %in% c("puniform")) %>%
select(id, condition, k, k.label, delta, delta.label, qrpEnv, qrp.label, censor, censor.label, tau, tau.label, b0_estimate, b0_comment) %>%
group_by(condition, k, k.label, delta, delta.label, qrpEnv, qrp.label, censor, censor.label, tau, tau.label) %>%
summarise(
regular_perc = sum(b0_comment == 0) / n(),
noSig_perc = sum(b0_comment == 1) / n(),
barelySig_perc = sum(b0_comment == 2) / n()
)
print(puniform_comments, n=432)
# table collapsed across all conditions:
res.wide.red %>% filter(method %in% c("puniform")) %>% count(b0_comment) %>% select("n")/432000*100
# table per delta (i.e., at which deltas did the special case occur?):
# --> mostly at delta==0
res.wide.red %>% filter(method %in% c("puniform")) %>% group_by(delta) %>% count(b0_comment) %>% mutate(perc=n/108000)
# same for p-curve: How often does it return exactly 0? (Well, the optimizer converges on somethin like 0.0001, not exactly 0)
pcurve <- res.wide.red %>% filter(method %in% c("pcurve"))
sum(pcurve$b0_estimate < 0.0001, na.rm=TRUE)/432000
## ======================================================================
## How many estimates converge?
## ======================================================================
load("dataFiles/summ.RData")
# reduced set for revision
summ2 <- summ %>% filter(method %in% c("reMA", "TF", "PETPEESE", "pcurve", "puniform", "3PSM", "WAAP-WLS")) %>%
mutate(method = factor(method, levels=c("reMA", "TF", "WAAP-WLS", "pcurve", "puniform", "PETPEESE", "3PSM"), labels=c("RE", "TF", "WAAP-WLS", "p-curve", "p-uniform", "PET-PEESE", "3PSM"), ordered=TRUE))
# which method has less than 100% convergence? --> RE, WAAP-WLS and PET-PEESE always converge
convRate0 <- summ2 %>%
ungroup() %>%
select(k, delta, qrpEnv, censor, tau, method, n.validEstimates) %>%
spread(method, n.validEstimates)
# overall convergence rate (across all conditions)
convRate0 %>%
select(RE, TF, 'WAAP-WLS', 'p-curve', 'p-uniform', 'PET-PEESE', '3PSM') %>%
summarise_all(mean, na.rm=TRUE)
# When does a method fail?
## TF
convRate0 %>% filter(TF < 800) %>% print(n=100)
## p-curve
convRate0 %>% filter(`p-curve` < 900) %>% print(n=100)
## p-uniform
convRate0 %>% filter(`p-uniform` < 500) %>% print(n=100)
## 3PSM
convRate0 %>% filter(`3PSM` < 500) %>% print(n=100)
# prepare the full table
convRate <- summ2 %>% ungroup() %>%
filter(!method %in% c("RE", "WAAP-WLS", "PET-PEESE")) %>% # remove methods with 100% convergence
select(k, delta, qrpEnv, censor, tau, method, n.validEstimates) %>%
mutate(convRate = paste0(round(n.validEstimates/10), "%")) %>%
select(-n.validEstimates) %>%
arrange(k, delta, qrpEnv, censor, tau, method)
convRate.wide <- spread(convRate, method, convRate)
colnames(convRate.wide)[1:5] <- c("{k}", "{$\\delta$}", "{QRP}", "{PB}", "{$\\tau$}")
print(convRate.wide, n=432)
# print full table
library(xtable)
x1 <- xtable(convRate.wide, auto=TRUE, label="tab:convRate", caption="QRP = QRP Environment, PB = Publication bias")
print(x1, file="tex-exports/tab-convRate.tex", include.rownames=FALSE, sanitize.colnames.function=identity, tabular.environment="longtable", floating = FALSE)
## ======================================================================
## Average I^2 estimates in conditions without publication bias and without QRPs:
## i.e., what are the I^2 values that correspond to our chosen tau values?
## ======================================================================
I2 <- res.wide.red %>%
filter(method == "reMA", censor == "none", qrpEnv=="none", !is.na(I2_estimate)) %>%
select(k, k.label, delta, delta.label, tau, tau.label, I2_estimate) %>%
group_by(k, k.label, delta, delta.label, tau, tau.label) %>%
summarise(
I2.mean = mean(I2_estimate, na.rm=TRUE),
I2.SD = sd(I2_estimate, na.rm=TRUE)
) %>% arrange(tau, delta, k)
print(I2, n=100)
# stronger aggregation: aggregate over k
I2b <- res.wide.red %>%
filter(method == "reMA", censor == "none", qrpEnv=="none", !is.na(I2_estimate)) %>%
select(delta, delta.label, tau, tau.label, I2_estimate) %>%
group_by(delta, delta.label, tau, tau.label) %>%
summarise(
I2.mean = mean(I2_estimate, na.rm=TRUE),
I2.SD = sd(I2_estimate, na.rm=TRUE)
) %>% arrange(tau, delta)
I2b
# even stronger aggregation: aggregate over k and delta
I2c <- res.wide.red %>%
filter(method == "reMA", censor == "none", qrpEnv=="none", !is.na(I2_estimate)) %>%
select(tau, tau.label, I2_estimate) %>%
group_by(tau, tau.label) %>%
summarise(
I2.mean = mean(I2_estimate, na.rm=TRUE),
I2.SD = sd(I2_estimate, na.rm=TRUE)
) %>% arrange(tau)
I2c
## ======================================================================
## How many puniform and pcurve results are negative?
## ======================================================================
estNeg <- res.wide.red %>%
filter(method %in% c("puniform", "pcurve"), !is.na(b0_estimate)) %>%
#select(method, k.label, delta.label, tau.label, censor.label, b0_estimate) %>%
group_by(method, k.label, delta.label, tau.label, censor.label) %>%
summarise(
estNegPerc = sum(b0_estimate < 0)/n()
) %>% arrange(tau.label, delta.label, k.label)
print(estNeg, n=300)
# --> virtually all pcurve and puniform estimates are truncated at zero.
## ======================================================================
## ANOVA-style analysis: Which experimental factor explains variation in performance?
## (Not very illuminating)
## ======================================================================
load("dataFiles/summ.RData")
library(lsr)
a1 <- aov(RMSE ~ k.label*delta.label*qrp.label*censor.label*tau.label, data=summ %>% filter(method=="pcurve"))
e1 <- data.frame(etaSquared(a1))
e1[order(e1$eta.sq, decreasing=TRUE), ]
## ======================================================================
## Do TF and PET always/mostly disagree in the case of H0 + publication bias?
## ======================================================================
H0.PB <- res.wide.red %>%
filter(method %in% c("TF", "PET"), !is.na(b0_estimate), delta==0, qrpEnv=="none", censor=="high")
%>%
#select(method, k.label, delta.label, tau.label, censor.label, b0_estimate) %>%
group_by(method, k.label, delta.label, tau.label, censor.label) %>%
summarise(
estNegPerc = sum(b0_estimate < 0)/n()
) %>% arrange(tau.label, delta.label, k.label)
ggplot(H0.PB, aes(x=b0_estimate, color=method)) + geom_density()