-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults1.Rnw
319 lines (260 loc) · 13.8 KB
/
results1.Rnw
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
% Results I .Rnw File
<<parent_tores1,include = F>>=
set_parent('main.Rnw') # Set the parent document preamble
@
\section{Results}
\label{sec:findings}
\subsection{Potential drivers of the increase in corruption tolerance}
As pointed out previously, the corruption tolerance increase happened at the same time as other key events. First, AB indicators denote a political crisis, as support for President Rafael Correa's regime took a sharp hit. Second, a recession hit Ecuador due to a commodity price collapse, an earthquake and other circumstances. Below, Figure \ref{fig:ecua_pol} shows several public opinion indicators and Figure \ref{fig:ecua_ec} displays economic conditions, both observed and perceived from 2014 to 2019.
% Create the data to be used for the political opinion variables:
<<political-graph-data, cache = T>>=
# Wrangle the time series of confidence in the president
political_graph_df<-
pconf_time %>%
select(year,
pres_conf_dicYes,
se.pres_conf_dicYes) %>%
rename(perc = pres_conf_dicYes,
se = se.pres_conf_dicYes) %>%
mutate(legend = '% who confide in the President') %>%
filter(year != 2004,
year != 2006)
# The same but for the job approval rating variable
japrov_df_g<-
japrov_time %>%
select(year,
pres_aprov_dicYes,
se.pres_aprov_dicYes) %>%
rename(perc = pres_aprov_dicYes,
se = se.pres_aprov_dicYes) %>%
mutate(legend = '% who approve the President\'s job performance')
# Same for leftists and rightists
leftists_df_g<-
leftist_time %>%
rename(perc = leftist) %>%
mutate(legend = '% who identiy with the political left')
rightists_df_g<-
rightist_time %>%
rename(perc = rightist) %>%
mutate(legend = '% who identiy with the political right')
# Now unite all of these in the same dataframe to plot it.
political_graph_df<-
bind_rows(political_graph_df,
japrov_df_g,
leftists_df_g,
rightists_df_g)
rownames(political_graph_df)<-NULL
@
% Now do the graph
\begin{figure}[htbp]
\centering
\fbox{
\begin{minipage}{\textwidth}
\caption{Ecuadorian public opinion indicators, 2004-2019}
\label{fig:ecua_pol}
<<political_graph, fig.align='center', include = T, echo = F, fig.width = 10, cache = T>>=
pol_graph<-ggplot(political_graph_df,
aes(x = year, y = perc, color = legend, group = legend))+
geom_line(size = 0.8)+
scale_color_manual(values = c('#FF4500', '#800080', '#800000', '#6495ED'))+
geom_point(size = 2.15)+
geom_line(aes(x = year,
y = perc - 1.96*se),
size = 0.7,
color = 'grey50',
linetype = 'dotted')+
geom_line(aes(x = year,
y = perc + 1.96*se),
size = 0.7,
color = 'grey50',
linetype = 'dotted')+
annotate('rect', xmin = 2.5, xmax = 7.5, ymin = 0, ymax = 0.75,
alpha = 0.1, fill = 'green')+
annotate('label', x = 5, y = 0.4, label = 'Correa Tenure', family = 'serif')+
annotate('rect', xmin = 0.5, xmax = 2.5, ymin = 0, ymax = 0.75,
alpha = 0.1, fill = 'red')+
annotate('label', x = 1.5, y = 0.5, label = 'Gutiérrez-Palacio Tenure', family = 'serif')+
annotate('rect', xmin = 7.5, xmax = 9, ymin = 0, ymax = 0.75,
alpha = 0.1, fill = 'blue')+
annotate('label', x = 8.3, y = 0.5, label = 'Moreno Tenure', family = 'serif')+
scale_y_continuous(breaks = c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9),
labels = c(10, 20, 30, 40, 50, 60, 70, 80, 90))+
labs(x = '',
y = 'Percent (%) of Ecuadorian voting-age population',
color = '')+
theme_bw()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
text = element_text(size = 12, family = 'serif'),
axis.ticks.y = element_blank(),
legend.position = c(0.22,0.88),
legend.background = element_blank())
pol_graph
@
\textbf{Note:} The graph shows time series for political public opinion questions asked in the AB. Percentages are estimated as explained in \hyperref[app:first]{Appendix A} and error bars show 95\% confidence intervals considering design effects. Figure prepared by the author. \end{minipage}
}
\end{figure}
The AB data shows that indeed the President reached an all-time high popularity in 2014 and then a severe drop in 2016. This is seen through the percent of people who approve the President's job performance and the percent who report confidence in him. Another notable change in the political landscape is the way that voting-age population politically identified. There was a strong increase of the people who identified as the \enquote{right}, while those who identified with the \enquote{left} did not see significant changes.
Regarding the economic recession, \textcite{Orozco.2015} holds that although the commodity price collapse in 2008 was greater, there was little reduction in economic activity as the country had greater possibilities of international financing and savings left over from past oil funds, which were used to keep government expenditure high. In 2016, as savings eroded and government debt had grown bigger, the economy stagnated significantly for the first time in the Correa administration. Combined with the lack of competitiveness in exports due to US dollar appreciations and the poor public finance administration \parencite{Hurtado.2018}, the country fell into a deep economic recession. While the official GDP figures may show only a small reduction in GDP growth, \textcite{Hurtado.2018} holds that these figures are overestimated.
% Here I create my graph, but I need to load some libraries first and create the data needed for my graphs.
<<load-libraries-data-results, cache = T>>=
# Source the tabulations script where I use all required tabulations.
source('scripts/tabulations.R')
# Load my libraries
library(Quandl) # To extract financial data from several sources
library(WDI) # World Bank database
library(patchwork) # Combine plots into one sole output
library(ggpubr) # Arrange plots (another way)
library(DataCombine) # Calculate a PCT change
# Create my data for the graphs
# Load the WTI oil barrel price data from FRED using the Quandl library
#
# oil_price <- Quandl("FRED/DCOILWTICO",
# type = "raw",
# collapse = "monthly",
# start_date = "2004-1-1",
# end_date = "2019-12-31")
# Save it, I do this because the code won't run because I'll need a FRED API after a while. I comment out this code so no errors pop out in somebody else's attempt to run the code.
# save(oil_price, file = 'data/oil.Rdata')
# Load the data (if you didn't run that code by yourself)
load('data/oil.Rdata')
# Order by time
oil_price<-
oil_price %>%
arrange(desc(Date))
# Calculate a percent change
oil_price<-
oil_price %>%
change('Value',
NewVar = 'pct_change',
slideBy = -1,
type = 'percent')
# GDP growth rate through the WDI package to extract data from the World Bank database.
gdp_wdi<-WDI(country = 'EC',
indicator = 'NY.GDP.MKTP.KD.ZG')
unem_wdi<-WDI(country = 'EC',
indicator = 'SL.UEM.TOTL.ZS')
# Wrangle the GDP
gdp_wdi<-
gdp_wdi %>%
select(NY.GDP.MKTP.KD.ZG, year) %>%
rename(growth = NY.GDP.MKTP.KD.ZG) %>%
relocate(year, .before = growth) %>%
filter(year >= 2004, year <= 2019)
# Wrangle the unemployment
unem_wdi<-
unem_wdi %>%
select(SL.UEM.TOTL.ZS, year) %>%
rename(growth = SL.UEM.TOTL.ZS) %>%
relocate(year, .before = growth) %>%
filter(year >= 2004, year <= 2019)
# Join the two series for ggplot graphing
# Add the legend for the gdp_wdi
gdp_wdi$legend<-'Real GDP Growth Rate'
unem_wdi$legend<-'Unemployment (ILO estimate)'
# Then merge
econ_graph_df<-bind_rows(gdp_wdi,
unem_wdi)
# Now, wrangle the economic indicators for the LAPOP survey
# Crate a new data frame to later append to the econ_g
econ_lapop<-
ecsit_time %>%
rename('perc' = econ_sitWorse,
'se' = se.econ_sitWorse) %>%
select(year, perc, se) %>%
mutate(perc = perc * 100 %>% as.numeric(),
legend = 'Worse Economic Situation')
# Now wrangle the unemployment rate (both types, open and closed) from the LAPOP survey
unem_lapop<-
unem_time %>%
rename('perc' = unem2_4a) %>%
select(year, perc, se) %>%
mutate(perc = perc * 100 %>% as.numeric(),
legend = 'Unemployed')
# Now join both bases as well as the unemployment
econ_lapop<-
bind_rows(econ_lapop,
unem_lapop) %>%
filter(perc > 0) # Eliminate the rows where I have an indicator not asked in that year.
rownames(econ_lapop)<-c() # Delete the row names, as they are redundant with the year.
@
% Now I do the graph:
\begin{figure}[htbp]
\begin{center}
\fbox{
\begin{minipage}{\textwidth}
\caption{Ecuadorian economic conditions 2004-2019}
\label{fig:ecua_ec}
<<econ_graph, fig.align='center', include = T, echo = F, fig.width = 10, fig.height= 10, cache = T>>=
econ_graph<-ggplot(econ_graph_df,
aes(x = year, y = growth, color = legend, group = legend))+
geom_line(size = 0.8)+
geom_hline(yintercept = 0, linetype = 'longdash')+
scale_colour_brewer(palette = 'Set2')+
geom_point(size = 2.15)+
scale_x_continuous(breaks = c(2004,2006,2008,2010,2012,2014,2016,2018))+
theme_bw()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
text = element_text(size = 12, family = 'serif'),
legend.position = c(0.8,0.9),
legend.background = element_blank())+
labs(x = '',
y = 'Percentage points (%)',
color = '',
title = 'World Bank macroeconomic indicators')
oil_graph<-ggplot(oil_price,
aes(x = Date, y = Value))+
scale_x_date(date_labels = '%Y', date_breaks = '1 year',
limit = c(as.Date('2004-01-01'), as.Date('2019-12-31')))+
geom_line(size = 0.8, color = 'orange')+
geom_point(size = 1)+
scale_y_continuous(breaks = c(seq(from = 30, to = 150, by = 20)))+
theme_bw()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
text = element_text(size = 12, family = 'serif'),
legend.position = c(0.13,0.20),
legend.background = element_blank())+
labs(x = '',
y = 'USD per WTI barrel',
title = 'Monthly WTI oil prices')
ecsit_graph<-ggplot(econ_lapop,
aes(x = year,
y = perc,
color = legend,
group = legend))+
geom_line(aes(x = year,
y= perc),
size = 0.8)+
geom_line(aes(x = year,
y = perc - 1.96*100*se),
size = 0.7,
color = 'grey50',
linetype = 'dotted')+
geom_line(aes(x = year,
y = perc + 1.96*100*se),
size = 0.7,
color = 'grey50',
linetype = 'dotted')+
scale_colour_brewer(palette = 'Set1')+
geom_point(size = 2.15)+
theme_bw()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
text = element_text(size = 12, family = 'serif'),
legend.position = c(0.14,0.2),
legend.background = element_blank())+
labs(x = '',
y = 'Percent of voting-age Ecuadorians',
color = '',
title = 'Unemployment and economic situation in the AB survey')
econ_graph + oil_graph + ecsit_graph +
plot_layout(nrow = 3,
heights = c(4,4,4))
@
\textbf{Note:} Time series line graphs showing key economic indicators for the country between 2004 and 2019. Real GDP growth and unemployment rates extracted from the World Bank's World Development Indicators. WTI oil barrel prices extracted from FRED. The rest are estimates computed with the open-access AB databases, which include 95\% confidence intervals adjusted for design effects. See \hyperref[app:first]{Appendix A} for details on calculations. Figure prepared by the author.
\end{minipage}}
\end{center}
\end{figure}
Figure \ref{fig:ecua_pol} shows several indicators of public opinion in the country. The AB data shows that indeed the President reached an all-time high popularity in 2014 and then a severe drop in 2016. This is seen through the percent of people who approve the President's job performance and the percent who report confidence in him. Another notable change in the political landscape of this period is the way that voting-age population identified politically. There was a notable increase of the people who identified as the \enquote{right} of the political wings, while those who identified with the \enquote{left} did not see significant changes.