-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_analysis.R
149 lines (99 loc) · 3.36 KB
/
run_analysis.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
rm(list = ls())
# disable scientific notation
options(scipen = 999)
# set warning level
options(warn = -1)
start_time <- Sys.time()
source("R/functions.R")
# define needed packages
packages <- c("reshape2", "ggplot2", "readr", "readxl", "countrycode", "dplyr", "openxlsx", "beepr", "zoo", "foreach", "doParallel")
# check if needed packags are installed and do so, if not
ipak(packages)
# load default settings
source("R/settings.R")
# prepare common data
source("R/prepare_data.R")
# base ----
settings <- settings_default
# modify experiment name
settings$exp_name <- "base"
# modify model complexity
settings$regressors <- c("gdp_pc", "I(gdp_pc^2)", "spatial", "recession",
"pop_dens", "urb_share", "temporal")
settings$plotting <- FALSE
# prepare run
settings <- prepare_run(settings)
source("R/analysis.R")
# convergence measure -----
settings <- settings_default
# modify experiment name
settings$exp_name <- "conv"
# modify model complexity
settings$regressors <- c("gdp_pc", "I(gdp_pc^2)", "spatial", "recession",
"pop_dens", "urb_share", "temporal", "ratio_gdp_pc2glob")
settings$plotting <- FALSE
# prepare run
settings <- prepare_run(settings)
source("R/analysis.R")
# population weights ----
settings <- settings_default
# modify experiment name
settings$exp_name <- "conv_pop"
# modify model complexity
settings$regressors <- c("gdp_pc", "I(gdp_pc^2)", "spatial", "recession",
"pop_dens", "urb_share", "temporal", "ratio_gdp_pc2glob")
# use weighed regression
settings$regression_weights <- "pop"
settings$plotting <- FALSE
# prepare run
settings <- prepare_run(settings)
source("R/analysis.R")
# population weights with nx ----
# load default settings
settings <- settings_default
# modify experiment name
settings$exp_name <- "conv_pop_nx"
# modify model complexity
settings$regressors <- c("gdp_pc", "I(gdp_pc^2)", "spatial", "recession",
"pop_dens", "urb_share", "nx_pc_share", "temporal", "ratio_gdp_pc2glob")
# # other modifications
settings$plotting <- FALSE
# use weighed regression
settings$regression_weights <- "pop"
# prepare run
settings <- prepare_run(settings)
source("R/analysis.R")
# gdp weights ----
# load default settings
settings <- settings_default
# modify experiment name
settings$exp_name <- "conv_gdp"
# modify model complexity
settings$regressors <- c("gdp_pc", "I(gdp_pc^2)", "spatial", "recession",
"pop_dens", "urb_share", "temporal", "ratio_gdp_pc2glob")
# # other modifications
settings$plotting <- FALSE
# use weighed regression
settings$regression_weights <- "gdp"
# prepare run
settings <- prepare_run(settings)
source("R/analysis.R")
# gdp weights with nx ----
# load default settings
settings <- settings_default
# modify experiment name
settings$exp_name <- "conv_gdp_nx"
# modify model complexity
settings$regressors <- c("gdp_pc", "I(gdp_pc^2)", "spatial", "recession",
"pop_dens", "urb_share", "nx_pc_share", "temporal", "ratio_gdp_pc2glob")
# # other modifications
settings$plotting <- FALSE
# use weighed regression
settings$regression_weights <- "gdp"
# prepare run
settings <- prepare_run(settings)
source("R/analysis.R")
# compare runs ---
source("R/compare_runs.R")
# play a sound to that you know the run is finished and elasped time
beep(sound = 2, print(Sys.time() - start_time))