-
Notifications
You must be signed in to change notification settings - Fork 0
/
model6analysis.R
79 lines (68 loc) · 2.79 KB
/
model6analysis.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
rm('degreeResults')
rm('res')
rm('results')
## Collate the data into a neat results dataframe
allAgents <- NULL
for(rd in rawdata) {
rd$agents$agentCount <- rep(rd$model$agentCount,nrow(rd$agents))
rd$agents$agentDegree <- rep(rd$model$agentDegree,nrow(rd$agents))
rd$agents$decisionCount <- rep(rd$model$decisionCount,nrow(rd$agents))
rd$agents$modelDuration <- rep(rd$duration,nrow(rd$agents))
rd$agents$meanSensitivity <- rep(rd$model$other$sensitivity,nrow(rd$agents))
rd$agents$sdSensitivity <- rep(rd$model$other$sensitivitySD,nrow(rd$agents))
rd$agents$startingEgoBias <- rep(rd$model$other$startingEgoBias,nrow(rd$agents))
# rd$agents$adviceNoise <- rep(rd$model$other$adviceNoise,nrow(rd$agents))
rd$agents$badAdviceProb <- rep(rd$model$other$badAdviceProb,nrow(rd$agents))
allAgents <- rbind(allAgents, rd$agents)
}
rm('rawdata')
rm('rd')
# have to keep the same variable because of memory limitations
allAgents <- allAgents[allAgents$generation%%50 == 1
| (allAgents$generation%%25 ==1 & allAgents$generation < 250), ]
if(!require('tidyverse')) {
install.packages('tidyverse')
library(tidyverse)
}
style <- theme_light() +
theme(legend.position = 'top')
# egoBias
ggplot(allAgents,
aes(x=generation, y=egoBias,
colour = as.factor(adviceNoise),
shape = as.factor(meanSensitivity))) +
geom_hline(yintercept = 0.5, linetype = 'dashed') +
stat_summary(geom = 'point', fun.y = mean, size = 3) +
stat_summary(geom = 'errorbar', fun.data = function(x){data.frame(ymin=min(x), ymax=max(x))},
size = 1, alpha = 0.25) +
stat_summary(geom = 'errorbar', fun.data = mean_cl_boot, size = 0.25) +
scale_y_continuous(limits = c(0,1)) +
facet_wrap(~startingEgoBias, labeller = label_both) +
style
# fitness
prefix.m <- function(s) paste('m =',s)
prefix.sd <- function(s) paste('sd =',s)
ggplot(allAgents,
aes(x=generation, y=fitness/decisionCount,
colour = as.factor(adviceNoise),
shape = as.factor(adviceNoise))) +
stat_summary(geom = 'point', fun.y = mean, size = 3, alpha = 0.5) +
stat_summary(geom = 'errorbar', fun.data = mean_cl_boot, size = .5) +
facet_wrap(~startingEgoBias) +
style
ggplot(allAgents,
aes(x="", y=modelDuration,
colour = as.factor(adviceNoise),
shape = as.factor(adviceNoise))) +
geom_point(size = 3, position = position_dodge(width = 0.2)) +
facet_wrap(~startingEgoBias) +
style
ggplot(allAgents, aes(x = initialDecision, y = finalDecision,
colour = as.factor(adviceNoise),
shape = as.factor(adviceNoise))) +
geom_point(alpha = 0.05) +
geom_abline(slope = 1, intercept = 0) +
coord_fixed() +
# scale_y_continuous(limits = c(0,100)) +
# scale_x_continuous(limits = c(0,100)) +
style