-
Notifications
You must be signed in to change notification settings - Fork 9
/
jg_plot_sa.R
40 lines (29 loc) · 1.33 KB
/
jg_plot_sa.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
library(ggplot2)
library(dplyr)
library(tidyr)
library(methods)
source('utils/pc_sa.R', chdir = T)
theme_set(theme_bw(base_size = 20))
load("output/src_future.Rda")
ss <- correct_bias(src_future@result[[7]])
ss <- ss %>% mutate(var = ordered(var, levels = c('ideo','risk.tak','n.traders',
'n.edg', 'seg', 'true.model'),
labels = c('Ideology', "Risk tolerance",
'# Traders', '# Edges/Trader', 'Segmentation',
"True model")))
title <- bquote(atop(plain("Estimated Effects on Convergence of Beliefs"),plain("in Future Scenario ") ~
(R^2 == .(round(src_future@r_squared, 2)) * plain(', ') ~
n == .(length(src_future@sims)))))
p_sa <- ggplot(ss, aes(x = var, y = x_corr)) +
geom_hline(yintercept = 0, size = 1, color = 'dark gray') +
geom_point(size = 4) +
geom_errorbar(aes(ymax = max_ci, ymin = min_ci), width=0.25, size = 1) +
labs(x = NULL, y = "Partial Rank Correlation Coefficient",
title = title) +
ylim(c(-1,1)) +
theme(panel.grid.major.x = element_blank(),
axis.text.x = element_text(angle = 30, hjust=1, vjust=1))
print(p_sa)
pdf("jg_sa_future.pdf", width=8, height=8)
print(p_sa)
dev.off()