-
Notifications
You must be signed in to change notification settings - Fork 1
/
Table_03_OLS_CUSUM_test_BRIC_FEWNet.R
181 lines (116 loc) · 4.17 KB
/
Table_03_OLS_CUSUM_test_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
############### Test for Structural breakpoints - OLS-CUSUM Tests: BRIC ###############
# install.packages('zoo')
# install.packages('strucchange')
# install.packages('tseries')
# install.packages('sandwich')
library(zoo)
library(sandwich)
library(strucchange)
library(tseries)
set.seed(20240101) # For reproducibility, we are using this seed value
################## Brazil ############################
# Set the working directory
setwd("/FEWNet/dataset/brazil")
getwd()
# Data
cpi.df <- read.csv("Brazil_CPI_inf_rate_Monthly_base_mulvar_cpi_epu_gprc_202201.csv",header=TRUE)
cpi.df$date <- as.Date(cpi.df$date)
str(cpi.df)
# Convert Date into a numeric quantity
cpi.df$date_n <- as.numeric(cpi.df$date)
# Convert CPI inflation into a time series object
CPI_brazil <- ts(cpi.df$CPI_inflation_rate, start = 2003, end = 2021, frequency = 6)
CPI_brazil
length(CPI_brazil)
# Define a time period variable
time <- c(1:109)
# Identify the breakpoints
length(CPI_brazil)
CPI_brazil_bp <- breakpoints(CPI_brazil ~ time, h = 7)
CPI_brazil_bp
# Check for the statistical significance of the break-points
coef(CPI_brazil_bp)
# Check for the statistical significance of the break-points
addi_CPI_BP <- efp(CPI_brazil ~ breakfactor(CPI_brazil_bp), type = "OLS-CUSUM")
plot(addi_CPI_BP)
################## Russia ############################
# Set the working directory
setwd("/FEWNet/dataset/russia")
getwd()
# Data
cpi.df <- read.csv("RUS_CPI_inf_rate_Monthly_mulvar_epu_gprc_202201.csv",header=TRUE)
cpi.df$date <- as.Date(cpi.df$date)
str(cpi.df)
# Convert Date into a numeric quantity
cpi.df$date_n <- as.numeric(cpi.df$date)
str(cpi.df)
# Convert CPI inflation into a time series object
CPI_russia <- ts(cpi.df$cpi_inflation_rate, start = 2003, end = 2021, frequency = 6)
CPI_russia
length(CPI_russia)
# Define a time period variable
time <- c(1:109)
# Identify the breakpoints
length(CPI_russia)
CPI_russia_bp <- breakpoints(CPI_russia ~ time, h=7)
CPI_russia_bp
# Check for the statistical significance of the break-points
coef(CPI_russia_bp)
# Check for the statistical significance of the break-points
addi_CPI_BP <- efp(CPI_russia ~ breakfactor(CPI_russia_bp), type = "OLS-CUSUM")
plot(addi_CPI_BP)
################## India ############################
# Set the working directory
setwd("/FEWNet/dataset/india")
getwd()
# Data
cpi.df <- read.csv("India_CPI_inf_rate_Monthly_base_mulvar_cpi_epu_gprc_202201.csv",header=TRUE)
cpi.df$Date <- as.Date(cpi.df$Date)
str(cpi.df)
# Convert Date into a numeric quantity
cpi.df$date_n <- as.numeric(cpi.df$Date)
str(cpi.df)
# Convert CPI inflation into a time series object
CPI_india <- ts(cpi.df$CPI_inflation_Rate, start = 2003, end = 2021, frequency = 6)
CPI_india
length(CPI_india)
# Define a time period variable
time <- c(1:109)
# Identify the breakpoints
length(CPI_india)
CPI_india_bp <- breakpoints(CPI_india ~ time, h = 7)
CPI_india_bp
# Check for the statistical significance of the break-points
coef(CPI_india_bp)
# Check for the statistical significance of the break-points
addi_CPI_BP <- efp(CPI_india ~ breakfactor(CPI_india_bp), type = "OLS-CUSUM")
# addi_CPI_BP <- efp(CPI_india ~ breakfactor(CPI_india_bp), type = "Score-MOSUM")
plot(addi_CPI_BP)
################## China ############################
# Set the working directory
setwd("/FEWNet/dataset/china")
getwd()
# Data
cpi.df <- read.csv("China_CPI_inf_rate_Monthly_mulvariate_epu_gprc_202201.csv",header=TRUE)
cpi.df$date <- as.Date(cpi.df$date)
str(cpi.df)
# Convert Date into a numeric quantity
cpi.df$date_n <- as.numeric(cpi.df$date)
str(cpi.df)
# Convert CPI inflation into a time series object
CPI_china <- ts(cpi.df$cpi_inflation_rate, start = 2003, end = 2021, frequency = 6)
CPI_china
length(CPI_china)
# Define a time period variable
time <- c(1:109)
# Identify the breakpoints
length(CPI_china)
CPI_china_bp <- breakpoints(CPI_china ~ time, h = 7)
CPI_china_bp
# Check for the statistical significance of the break-points
coef(CPI_china_bp)
# Check for the statistical significance of the break-points
addi_CPI_BP <- efp(CPI_china ~ breakfactor(CPI_china_bp), type = "OLS-CUSUM")
plot(addi_CPI_BP)
####################### End of Code ##############################
str(cpi.df)