-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathposter.R
179 lines (144 loc) · 7.76 KB
/
poster.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
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
### Script for poster plots ###################################################
# Setting Working directory
try(setwd("D:/Eigene Datein/Dokumente/Uni/Hertie/Materials/Master thesis/SecurityPolicyForecastingTournament"), silent = TRUE)
# load main script
source("main.R")
### Tournament section ########################################################
response.poster <- function(q){
ggplot(FO.plot, aes(x=eval(parse(text = fq[q])))) +
geom_density(alpha=.3, fill="#C02F39") +
geom_vline(data=filter(FO.plot2,
fq.id == paste("fq",as.character(q), sep = "") &
part.group == "all"),
aes(xintercept=mean, colour=part.group),
linetype="dashed", size=1.5) + # group average
labs(title = sapply(strwrap(as.character(FQ[q,2]), 70, simplify=FALSE),
paste, collapse="\n" ),
x = "What is the probability of this event to happen?",
y = "Distribution of estimates") + # labels
theme(axis.text = element_text(size = 13),
axis.title=element_text(size=14),
plot.title = element_text(size=18),
panel.background = element_blank(),
panel.grid.major = element_line(colour = "grey"),
aspect.ratio=2/4) + # axis + background
guides(fill=guide_legend(title="Participants")) + # legend title
scale_color_manual("Mean", values = c("#C02F39")) + # legend mean vline
expand_limits(x=c(0,1)) + # set range of x-axis
scale_x_continuous(labels=percent) + # percentages
geom_vline(xintercept=as.numeric(FQ[q,4]),
colour="#696969",
linetype="dashed", size=1.5,
show.legend = TRUE) # correct answer
}
response.poster(8)
ggsave(filename="plots/reponseFQ8.pdf", plot=response.poster(8), device=cairo_pdf)
ggsave(filename="plots/reponseFQ9.pdf", plot=response.poster(9), device=cairo_pdf)
ggsave(filename="plots/reponseFQ16.pdf", plot=response.poster(16), device=cairo_pdf)
ggsave(filename="plots/reponseFQ13.pdf", plot=response.poster(13), device=cairo_pdf)
ggsave(filename="plots/reponseFQ6.pdf", plot=response.poster(6), device=cairo_pdf)
# Brier distribution
brier.plot2 <- ggplot(SB, aes(x = brier.avg)) +
geom_histogram(binwidth=.05, position="dodge", fill = "#C02F39") + # bar type
theme_bw() +
theme(axis.title = element_text(size=18, colour = "#696969"), # Labels axis font size
axis.text = element_text(size=14, colour = "#696969"),
axis.line = element_line(colour = "#696969"),
axis.ticks = element_line(colour = "#696969")) +
labs( # title = "Brier score distribution",
x = "Brier score",
y = "Frequency") # labels))
# save brier score distribution
ggsave(filename="plots/brierPlot.pdf", plot=brier.plot2, device=cairo_pdf)
# Aggregation plot
ggsave(filename="plots/aggPlot.pdf", plot=agg.plot(17), device=cairo_pdf)
### Research section ##########################################################
# BNT Scores distribution
# Distribution of bnt scores
bnt.plot2 <- ggplot(SPFT, aes(x = bnt.s)) +
geom_bar(fill = "#C02F39") +
theme_bw() +
theme(axis.title = element_text(size=22, colour = "#696969"), # Labels axis font size
axis.text = element_text(size=18, colour = "#696969"),
axis.line = element_line(colour = "#696969"),
axis.ticks = element_line(colour = "#696969"),
title = element_text(size=24, colour = "#696969")) +
labs(title = "Distribution of Berlin Numeracy Test results",
x = "BNT Score (# of correct answers)",
y = "# of respondents") # labels
ggsave(filename="plots/bntPlot.pdf", plot=bnt.plot2, device=cairo_pdf)
# Correlation Mct-Brier Scores
ggsave(filename="plots/corBrierMctPlot.pdf", plot=cor.brier.mct.plot, device=cairo_pdf)
cor.brier.mct.plot2 <- ggplot(filter(SPFT, !is.na(mct.c)), aes(x=mct.c, y=brier.avg)) +
geom_point(shape=1) + # Use hollow circles
theme_bw() +
theme(axis.title = element_text(size=18, colour = "#696969"), # Labels axis font size
axis.text = element_text(size=14, colour = "#696969"),
axis.line = element_line(colour = "#696969"),
axis.ticks = element_line(colour = "#696969")) +
labs(x = "Moral Competency Score",
y = "Brier Score") # labels
ggsave(filename="plots/corBrierMctPlot_noline.pdf", plot=cor.brier.mct.plot2, device=cairo_pdf)
cor.brier.mct.plot3 <- ggplot(filter(SPFT, !is.na(mct.c)), aes(x=mct.c, y=brier.avg)) +
geom_point() +
theme_bw() +
theme(axis.title = element_text(size=18, colour = "#696969"), # Labels axis font size
axis.text = element_text(size=14, colour = "#696969"),
axis.line = element_line(colour = "#696969"),
axis.ticks = element_line(colour = "#696969")) +
labs(x = "Moral Competency Score",
y = "Brier Score") # labels
ggsave(filename="plots/corBrierMctPlot_noline2.pdf", plot=cor.brier.mct.plot3, device=cairo_pdf)
# Correlation Brier log(time) correlation
ggsave(filename="plots/corBrierTimeLogPlot.pdf", plot=cor.brier.time.log.plot, device=cairo_pdf)
cor.brier.time.log.plot2 <- ggplot(filter(SPFT, !is.na(time.fq.sec)),
aes(x=time.fq.sec.log, y=brier.avg)) +
geom_point(shape=1) + # Use hollow circles
theme_bw() +
theme(axis.title = element_text(size=20, colour = "#696969"), # Labels axis font size
axis.text = element_text(size=16, colour = "#696969"),
axis.line = element_line(colour = "#696969"),
axis.ticks = element_line(colour = "#696969")) +
labs(x = "log(time)",
y = "Brier score") # labels
ggsave(filename="plots/corBrierTimeLogPlot_noline.pdf", plot=cor.brier.time.log.plot2, device=cairo_pdf)
cor.brier.time.log.plot3 <- ggplot(filter(SPFT, !is.na(time.fq.sec)),
aes(x=time.fq.sec.log, y=brier.avg)) +
geom_point() +
theme_bw() +
theme(axis.title = element_text(size=20, colour = "#696969"), # Labels axis font size
axis.text = element_text(size=16, colour = "#696969"),
axis.line = element_line(colour = "#696969"),
axis.ticks = element_line(colour = "#696969")) +
labs(x = "log(time)",
y = "Brier score") # labels
ggsave(filename="plots/corBrierTimeLogPlot_noline2.pdf", plot=cor.brier.time.log.plot3, device=cairo_pdf)
# Correlation Brier linear time
ggsave(filename="plots/corBrierTimePlot.pdf", plot=cor.brier.time.plot, device=cairo_pdf)
cor.brier.time.plot2 <- ggplot(filter(SPFT, !is.na(time.fq.sec)),
aes(x=time.fq.sec, y=brier.avg)) +
geom_point(shape=1) + # Use hollow circles
# geom_line(data = log.model.df,
# aes(x, y, color = "Log Model"),
# size = 2, linetype = 1, color = "#C02F39") +
theme_bw() +
theme(axis.title = element_text(size=20, colour = "#696969", family = "serif"), # Labels axis font size
axis.text = element_text(size=16, colour = "#696969"),
axis.line = element_line(colour = "#696969"),
axis.ticks = element_line(colour = "#696969")) +
labs(x = "time in min (linear)",
y = "Brier score") # labels
ggsave(filename="plots/corBrierTimePlot_noline.pdf", plot=cor.brier.time.plot2, device=cairo_pdf)
cor.brier.time.plot3 <- ggplot(filter(SPFT, !is.na(time.fq.sec)),
aes(x=time.fq.sec, y=brier.avg)) +
geom_point() +
theme_bw() +
theme(axis.title = element_text(size=20, colour = "#696969"), # Labels axis font size
axis.text = element_text(size=16, colour = "#696969"),
axis.line = element_line(colour = "#696969"),
axis.ticks = element_line(colour = "#696969")) +
labs(x = "time in min (linear)",
y = "Brier score") # labels
ggsave(filename="plots/corBrierTimePlot_noline2.pdf", plot=cor.brier.time.plot3, device=cairo_pdf)
# Hypothesis 3 time
ggsave(filename="plots/hypo3TimePlot.pdf", plot=hypo3.time.plot, device=cairo_pdf)