-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10_funnel_plot_p_curve.R
62 lines (46 loc) · 1.64 KB
/
10_funnel_plot_p_curve.R
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
# Create pcurve to check for pub bias
# 5.29.20 KLS
# load required packages
library(here)
library(meta)
library(metafor)
library(dmetar)
library(ggplot2)
# load source functions
# set hard-coded variables
file <- 'cor_model.RDS'
# load data
m.cor <- readRDS(here::here('output', file))
# Contor funnel plot 1
png(file = 'figs/funnelplot.png', width = 800, height = 800)
meta::funnel(m.cor, xlim = c(-1.5,.5),
contour = c(.95, .975, .99),
col.contour=c("darkblue","blue","lightblue"))
legend(-1.5, 0, c("p < 0.05", "p<0.025", "< 0.01"), bty = "n",
fill=c("darkblue","blue","lightblue"))
dev.off()
# Contor funnel plot 2
png(file = 'figs/funnelplot2.png', width = 800, height = 800)
meta::funnel(m.cor, xlim = c(-1.5,.5),
contour = c(.95, .975, .99),
col.contour=c("gray35","gray55","gray75"))
legend(-1.5, 0, c("p < 0.05", "p<0.025", "< 0.01"), bty = "n",
fill=c("gray35","gray55","gray75"))
dev.off()
# Regular funnel plot
png(file = 'figs/funnelplot3.png', width = 800, height = 800)
meta::funnel(m.cor, xlim = c(-1.5,.5))
dev.off()
# for presentation
ggsave(file = here::here('figs', 'funnelplot.svg'), plot = meta::funnel(m.cor, xlim = c(-1.5,.5)), width = 5, height = 5)
# Eggers test ####
eggers.test(x = m.cor)
# pcurve analysis ####
png(file = 'figs/pcurve.png', width = 500, height = 500)
pcurve(m.cor)
dev.off()
pcurve(m.cor, effect.estimation = TRUE, N = m.cor$n, dmin = 0, dmax = 1)
# for presentation
ggsave(file = here::here('figs', 'pcurve.svg'), plot = pcurve(m.cor), width = 5, height = 5)
# post-code editing out of % signs per reviewer request
rm(m.cor, file)