-
Notifications
You must be signed in to change notification settings - Fork 0
/
shocks.R
58 lines (43 loc) · 1.48 KB
/
shocks.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
#### alpha param shocks analysis
library(tidyverse)
library(stringr)
library(knitr)
library(kableExtra)
library(RColorBrewer)
rm(list = ls())
source("plot_funs.R")
shock_df1 <- read_csv("data/julia/results_0125_0075_shoct_85_85.csv") %>%
bind_cols(tibble(model = rep(1L, 170)))
shock_df2 <- read_csv("data/julia/results_012_006_0085_85_45_40.csv") %>%
bind_cols(tibble(model = rep(2L, 170)))
shock_df3 <- read_csv("data/julia/results_015_012_006_0085_40_40_40_50.csv") %>%
bind_cols(tibble(model = rep(3L, 170)))
######################
var_names <- c("carrier" = "Niezdiagnozowany", "infected" = "Zdiagnozowany", "exposed" = "Inkubacja")
plt1 <- shock_df1 %>%
plot_multi(names(var_names), var_names)
ggsave("figures/shock1.eps")
plt2 <- shock_df2 %>%
plot_multi(names(var_names), var_names)
ggsave("figures/shock2.eps")
plt3 <- shock_df3 %>%
plot_multi(names(var_names), var_names)
ggsave("figures/shock3.eps")
######################
do.call(
bind_rows,
list(shock_df1, shock_df2, shock_df3) %>%
map(~ rowid_to_column(.x, "time"))
) %>%
mutate(model = as.factor(model)) %>%
select(model, time, all_of(names(var_names))) %>%
pivot_longer(all_of(names(var_names)), names_to = "type") %>%
ggplot(aes(x = time, y = value, colour = type)) +
geom_line() +
labs(x = "Czas",
y = "Liczba agentów",
colour = "Stan",
shape = "Model") +
scale_colour_hue(labels = var_names) +
facet_wrap(~ model, nrow = 1)
ggsave("figures/merged_shocks.eps")