-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFigure1_1workstream_bestModels_alternative.Rmd
119 lines (84 loc) · 3.78 KB
/
Figure1_1workstream_bestModels_alternative.Rmd
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
---
title: "input"
author: "Pierre Nouvellet"
date: "2019-07"
---
```{r options, include = FALSE, message = FALSE, warning = FALSE, error = FALSE}
library(knitr)
library(Hmisc)
library(EpiEstim)
library(zoo)
library(latex2exp)
opts_chunk$set(collapse = TRUE)
opts_chunk$set(fig.path='figs/', fig.keep='high',
dev=c('png'), fig.width=9, fig.height=6, cache=FALSE,
tidy=FALSE, warning=FALSE, fig.show="asis"
)
```
# input data
```{r}
# source(file = '../inputProcessing/date_input.r')
source(file = 'Rscript/niceplot_bestmodel_alt.R')
```
## make figure1
```{r}
inputs<- readRDS(file=
'../../../../Dropbox (SPH Imperial College)/Mobility.2.0.Save/Saved_file/inputProcessing/Rdata/inputs.rds')
names(inputs)
data_stream <- names(inputs$M_process_mat )
# for(i in 1:length(data_stream)){
# dir.create(path = paste0('../../../../Dropbox (SPH Imperial College)/Mobility.2.0.Save/Saved_file/figure1/figs/',data_stream[i]))
# }
res_base <- readRDS(file =
paste0('../../../../Dropbox (SPH Imperial College)/Mobility.2.0.Save/Saved_file/EpiEstim/Rdata/output_EpiE.rds' ))
si <- 2
# alternatives
country_alt <- c('Brazil', 'France', 'Italy',
'Mexico', 'Philippines', 'Spain',
'United_Kingdom', 'USA')
stream_alt <- rep("transit",length(country_alt))
stream_alt[c(3,6)] <- c('walking','driving')
stream_alt2 <- paste0(stream_alt,' (A)')
# for (Mdata in data_stream[12]){
# Mdata = data_stream[12]
fd.name=paste0('../../../../Dropbox (SPH Imperial College)/Mobility.2.0.Save/Saved_file/figure1/fig_BestModels/alt')
dir.create(fd.name)
for(j in 1:length(country_alt)){
Mdata <- stream_alt[j]
res_m <- readRDS( file = paste0('../../../../Dropbox (SPH Imperial College)/Mobility.2.0.Save/Saved_file/FitModels/R0_beta_Over/Rdata/output_over_form_',Mdata,'.rds' ))[[si]]
res_summary <- readRDS( file = paste0('../../../../Dropbox (SPH Imperial College)/Mobility.2.0.Save/Saved_file/FitModels/R0_beta_Over/Rdata/output2_over_form_',Mdata,'.rds' ) )[[si]]
res_m2 <- readRDS( file = paste0('../../../../Dropbox (SPH Imperial College)/Mobility.2.0.Save/Saved_file/FitModels/R0_beta_tD_Over/Rdata/output_over_form_',Mdata,'.rds' ))[[si]]
res_summary2 <- readRDS( file = paste0('../../../../Dropbox (SPH Imperial College)/Mobility.2.0.Save/Saved_file/FitModels/R0_beta_tD_Over/Rdata/output2_over_form_',Mdata,'.rds' ) )[[si]]
# n_country <- length(res_m$country)
country <- res_m$country
country_initial <- names(inputs$D)[-1]
# corr_across <- list(Robs = res_base[[si]]$resEpi$median_R,
# Rpred = res_summary2$results_full_Rt_D2$median_R,
# Tc = res_summary2$results_full_Rt_D2$median_R)
# corr_across$Tc[,2:(length(country)+1)] <- 1
#
i <- which(country %in% country_alt[j])
# for (i in 1:n_country){
mu_id = 18.8
k <- which(country_initial %in% country[i])
Change <- as.numeric(round(res_m$resMCMC$DIC[i]) - round(res_m2$resMCMC$DIC[i]) >= 0)
niceplot(i, res_summary, res_base, inputs)
# # f <- 1:nrow(res_base[[si]]$resEpi$S_below.5) #
# # f <- f[which(res_base$resEpi$CV_below.2[,i+1])]
# corr_across[[1]][,i+1] <- res_base[[si]]$resEpi$median_R[,i+1]
# # f <- which(res_summary$results_full_Rt_D2$median_R[,i+1] != 0)
# if (Change==0){
#
# corr_across[[2]][,i+1] <- res_summary$results_full_Rt_D2$median_R[,i+1]
# }else{
# # second predictions
# corr_across[[2]][,i+1] <- res_summary2$results_full_Rt_D2$median_R[,i+1]
# mtc <- median(res_m2$resMCMC$theta[,4*length(country)+i]) + mu_id
# corr_across[[3]][round(mtc):nrow(corr_across[[2]]),i+1] <- 2
#
# }
# plot(x,x2)
# }
# saveRDS(corr_across,file = paste0(Mdata,'_corr.rds'))
}
```