-
Notifications
You must be signed in to change notification settings - Fork 1
/
Figure_06_GR_tests_24M_BRIC_FEWNet.R
226 lines (185 loc) · 8.32 KB
/
Figure_06_GR_tests_24M_BRIC_FEWNet.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
################################## Figure 06 : Giacomini & Rossi Test ###################
# GR Tests for BRIC Countries: 24 months ahead forecasts
# install.packages('murphydiagram')
# install.packages('changepoint')
library(murphydiagram)
library(changepoint)
set.seed(20240101) # For reproducibility, we are using this seed value
########################### Brazil #######################
# Working directory
setwd("/FEWNet/dataset/brazil")
getwd()
# Brazil: 24M forecasts from FEWNet, AR and XGBoost Models datasets
data_brazil_24M <- read.csv("GR_test_brazil_24M_data.csv",header=TRUE)
str(data_brazil_24M)
# Convert date into numeric entity
tml <- as.numeric(data_brazil_24M$Date_Year)
tml
# Compute extremal scores of FEWNet and Test Data
score_FEWNet <- extremal_score(x = data_brazil_24M$FEWNet_24M,
y = data_brazil_24M$test_data_24M,
theta = 6)
score_FEWNet
# Compute extremal scores of AR model and Test Data
score_AR <- extremal_score(x = data_brazil_24M$AR_24M,
y = data_brazil_24M$test_data_24M,
theta = 6)
score_AR
# Compute extremal scores of XGBoost and Test Data
score_XGBoost <- extremal_score(x = data_brazil_24M$XGBoost_24M,
y = data_brazil_24M$test_data_24M,
theta = 12)
score_XGBoost
# GR test - plot: FEWNet Vs. AR
fluct_test_fewnet_ar_24m <- fluctuation_test(score_FEWNet,
score_AR,
mu = 0.3,
conf_level = 0.10,
time_labels = tml,
lag_truncate = 1)
fluct_test_fewnet_ar_24m
# GR test - plot: FEWNet Vs. XGBoost
fluct_test_fewnet_xgboost_24m <- fluctuation_test(score_FEWNet,
score_XGBoost,
mu = 0.1,
conf_level = 0.10,
time_labels = tml,
lag_truncate = 1)
fluct_test_fewnet_xgboost_24m
########################### Russia #######################
# Working directory
setwd("/FEWNet/dataset/russia")
getwd()
# Russia: 24M forecasts from FEWNet, AR and XGBoost Models datasets
data_russia_24M <- read.csv("GR_test_russia_24M_data.csv",header=TRUE)
str(data_russia_24M)
# Convert date into numeric entity
tml <- as.numeric(data_russia_24M$Date_Year)
tml
# Compute extremal scores of FEWNet and Test Data
score_FEWNet <- extremal_score(x = data_russia_24M$FEWNet_24M,
y = data_russia_24M$test_data_24M,
theta = 6)
score_FEWNet
str(score_FEWNet)
# Compute extremal scores of AR and Test Data
score_AR <- extremal_score(x = data_russia_24M$AR_24M,
y = data_russia_24M$test_data_24M,
theta = 6)
score_AR
score_AR
# Compute extremal scores of XGBoost and Test Data
score_XGBoost <- extremal_score(x = data_russia_24M$XGBoost_24M,
y = data_russia_24M$test_data_24M,
# functional = "quantile",
theta = 12)
score_XGBoost
str(score_XGBoost)
# GR test - plot: FEWNet Vs. AR
fluct_test_fewnet_ar_24m <- fluctuation_test(score_FEWNet,
score_AR,
mu = 0.2,
conf_level = 0.10,
time_labels = tml,
lag_truncate = 1)
fluct_test_fewnet_ar_24m
# GR test - plot: FEWNet Vs. XGBoost
fluct_test_fewnet_xgboost_24m <- fluctuation_test(score_FEWNet,
score_XGBoost,
mu = 0.2,
conf_level = 0.10,
time_labels = tml,
lag_truncate = 1)
fluct_test_fewnet_xgboost_24m
########################### India #######################
# Working directory
setwd("/FEWNet/dataset/india")
getwd()
# India: 24M forecasts from FEWNet, AR and XGBoost Models datasets
data_india_24M <- read.csv("GR_test_india_24M_data.csv",header=TRUE)
str(data_india_24M)
# Convert date into numeric entity
tml <- as.numeric(data_india_24M$Date_Year)
tml
# Compute extremal scores of FEWNet and Test Data
score_FEWNet <- extremal_score(x = data_india_24M$FEWNet_24M,
y = data_india_24M$test_data_24M,
theta = 6)
score_FEWNet
str(score_FEWNet)
# Compute extremal scores of AR and Test Data
score_AR <- extremal_score(x = data_india_24M$AR_24M,
y = data_india_24M$test_data_24M,
# functional = "quantile",
# alpha = 0.8,
theta = 6)
score_AR
str(score_AR)
# Compute extremal scores of XGBoost and Test Data
score_XGBoost <- extremal_score(x = data_india_24M$XGBoost_24M,
y = data_india_24M$test_data_24M,
# functional = "quantile",
theta = 6)
score_XGBoost
str(score_XGBoost)
# GR test - plot: FEWNet Vs. AR
fluct_test_fewnet_ar_24m <- fluctuation_test(score_FEWNet,
score_AR,
mu = 0.5,
conf_level = 0.10,
time_labels = tml,
lag_truncate = 1)
fluct_test_fewnet_ar_24m
# GR test - plot: FEWNet Vs. XGBoost
fluct_test_fewnet_xgboost_24m <- fluctuation_test(score_FEWNet,
score_XGBoost,
mu = 0.1,
conf_level = 0.10,
time_labels = tml,
lag_truncate = 1)
fluct_test_fewnet_xgboost_24m
########################### China #######################
# Working directory
setwd("/FEWNet/dataset/china")
getwd()
# China: 24M forecasts from FEWNet, AR and XGBoost Models datasets
data_china_24M <- read.csv("GR_test_china_24M_data.csv",header=TRUE)
str(data_china_24M)
# Convert date into numeric entity
tml <- as.numeric(data_china_24M$Date_Year)
tml
# Compute extremal scores of FEWNet and Test Data
score_FEWNet <- extremal_score(x = data_china_24M$FEWNet_24M,
y = data_china_24M$test_data_24M,
theta = 3)
score_FEWNet
str(score_FEWNet)
# Compute extremal scores of AR and Test Data
score_AR <- extremal_score(x = data_china_24M$AR_24M,
y = data_china_24M$test_data_24M,
theta = 3)
score_AR
str(score_AR)
# Compute extremal scores of XGBoost and Test Data
score_XGBoost <- extremal_score(x = data_china_24M$XGBoost_24M,
y = data_china_24M$test_data_24M,
theta = 6)
score_XGBoost
str(score_XGBoost)
# GR test - plot: FEWNet Vs. AR
fluct_test_fewnet_ar_24m <- fluctuation_test(score_FEWNet,
score_AR,
mu = 0.6,
conf_level = 0.10,
time_labels = tml,
lag_truncate = 1)
fluct_test_fewnet_ar_24m
# GR test - plot: FEWNet Vs. XGBoost
fluct_test_fewnet_xgboost_24m <- fluctuation_test(score_FEWNet,
score_XGBoost,
mu = 0.2,
conf_level = 0.10,
time_labels = tml,
lag_truncate = 1)
fluct_test_fewnet_xgboost_24m
########################### End of Code: GR test ##############################