-
Notifications
You must be signed in to change notification settings - Fork 0
/
005_inter_mone.qmd
608 lines (502 loc) · 28.1 KB
/
005_inter_mone.qmd
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
---
title: "International monetary system"
author: "Luis Francisco Gomez Lopez"
date: 2023-07-11
format:
beamer:
colortheme: dolphin
fonttheme: structurebold
theme: AnnArbor
link-citations: true
linkcolor: blue
include-in-header:
- text: |
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}
\usepackage{xcolor}
bibliography: econ_glob_faedis.bib
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = FALSE,
warning = FALSE,
message = FALSE,
fig.align = "center")
```
```{r libraries}
library(tidyverse)
library(tidyquant)
library(lubridate)
library(moments)
library(timetk)
```
# Contents
- Please Read Me
- Purpose
- Analysis of exchange rates
- Simple model of exchange rates determination
- Implicit devaluation
- Acknowledgments
- References
# Please Read Me
- Check the message __Welcome greeting__ published in the News Bulletin Board.
- Dear student please edit your profile uploading a photo where your face is clearly visible.
- The purpose of the virtual meetings is to answer questions and not to make a summary of the study material.
- This presentation is based on [@wild_international_2020, Chapter 10]
# Purpose
Analyze the importance of exchange rates to international business management and the factors that determine them
# Analysis of exchange rates
- Knowing the data
+ __Variable__: Market Representative Exchange Rate (MRE)[^1] COP/USD
+ Calculation methodology: [@banrep_circular_2018]
+ Only includes operations agreed by the Exchange Market Intermediaries (EMI)[^2] with other entities supervised by the Superintendencia Financiera de Colombia (SFC) and with the Nación - Ministerio de Hacienda y Crédito Público
+ The MRE is calculated and certified daily by the SFC with the operations of the day and will be effective for the next day
[^1]: Tasa de Cambio Representativa del Mercado (TRM) in spanish
[^2]: Intermediarios del Mercado Cambiario (IMC) in spanish
# Analysis of exchange rates
- Knowing the data
+ __Variable__: Market Representative Exchange Rate (MRE) COP/USD
+ The MRE in a business day following a holiday of the Federal Reserve banks of the United States of America will be the same MRE in effect on the holiday
+ For saturdays, sundays, holidays and those in which the Banco de la República does not provide the services of the "Sistema de Cuentas de Depósito", the MRE in force on the immediately following business day will apply
+ __Data source__: https://www.banrep.gov.co/ > Estadísticas > ¡NUEVO! Estadísticas Banrep > CATÁLOGO DE SERIES > Tasas de cambio y sector externo > Tasas de cambio nominales > Tasa Representativa del Mercado (TRM) > DESCARGAR
# Analysis of exchange rates
- Visualizing the data
```{r, out.width="80%"}
# Data
cop_usd_trm <- read_csv(file = "005_trm_cop_usd_consolidado_series.csv") %>%
set_names(nm = c("date", "trm")) %>%
mutate(trm_change = (trm - lag(trm)))
# Plot
cop_usd_trm %>%
ggplot(aes(x = date, y = trm)) +
geom_line(color = palette_light()[[1]]) +
geom_vline(xintercept = ymd("1999-09-25"),
color = palette_light()[[3]]) +
annotate(x = ymd("1995-01-01"),
y = 3500,
geom = "label",
color = "white",
fill = palette_light()[[1]],
label = str_glue("On 1999-09-25
the currency band system
was abandoned by
the Bank of the
Republic")) +
labs(x = "",
y = "COP/USD",
title = "Daily MRE (COP/USD)",
subtitle = str_glue("Period: {cop_usd_trm$date[1]} - {cop_usd_trm$date[length(cop_usd_trm$date)]},
Observations: {length(cop_usd_trm$trm)}"),
caption = str_glue("Data source: Banco de la República (Colombia) & Superintendencia Financiera de Colombia (SFC)
Last update: {cop_usd_trm$date[length(cop_usd_trm$date)]}")) +
theme(panel.border = element_rect(fill = NA, color = "black"),
plot.background = element_rect(fill = "#f3fcfc"),
panel.background = element_rect(fill = "#f3f7fc"),
legend.background = element_rect(fill = "#f3fcfc"),
plot.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
legend.title = element_text(face = "bold"),
axis.text = element_text(face = "bold"))
```
# Analysis of exchange rates
- Visualizing the data
```{r, out.width="80%"}
# Plot
bins <- 30
# Plot
cop_usd_trm %>%
ggplot() +
geom_histogram(aes(x = trm),
bins = bins + 1,
color = "black",
fill = palette_light()[[1]],
alpha = 0.8,
boundary = min(cop_usd_trm$trm)) +
scale_x_continuous(labels = scales::number_format(accuracy = 0.01),
breaks = seq(from = min(cop_usd_trm$trm),
to = max(cop_usd_trm$trm),
by = (max(cop_usd_trm$trm) - min(cop_usd_trm$trm)) / bins)) +
labs(x = "",
y = "",
title = "Frequency distribution: daily MRE (COP/USD)",
subtitle = str_glue("Period: {cop_usd_trm$date[1]} - {cop_usd_trm$date[length(cop_usd_trm$date)]}
Bins: {bins},
Observations: {length(cop_usd_trm$trm)}"),
caption = str_glue("Data source: Banco de la República (Colombia) & Superintendencia Financiera de Colombia (SFC)
Last update: {cop_usd_trm$date[length(cop_usd_trm$date)]}")) +
theme(panel.border = element_rect(fill = NA, color = "black"),
plot.background = element_rect(fill = "#f3fcfc"),
panel.background = element_rect(fill = "#f3f7fc"),
legend.background = element_rect(fill = "#f3fcfc"),
plot.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
legend.title = element_text(face = "bold"),
axis.text.x = element_text(face = "bold", angle = 90, vjust = 0.5),
axis.text.y = element_text(face = "bold"))
```
# Analysis of exchange rates
- Visualizing the data
```{r, out.width="80%"}
# Plot
cop_usd_trm %>%
ggplot() +
geom_histogram(aes(x = trm, y = after_stat(density)),
bins = bins + 1,
color = "black",
fill = palette_light()[[1]],
alpha = 0.8,
boundary = min(cop_usd_trm$trm)) +
geom_density(aes(x = trm),
color = palette_light()[[2]],
size = 1,
linetype = "longdash") +
scale_x_continuous(labels = scales::number_format(accuracy = 0.01),
breaks = seq(from = min(cop_usd_trm$trm),
to = max(cop_usd_trm$trm),
by = (max(cop_usd_trm$trm) - min(cop_usd_trm$trm)) / bins)) +
scale_y_continuous(labels = scales::number_format(accuracy = 0.0001)) +
labs(x = "",
y = "",
title = "Empirical probability density function: daily MRE (COP/USD)",
subtitle = str_glue("Period: {cop_usd_trm$date[1]} - {cop_usd_trm$date[length(cop_usd_trm$date)]}
Bins: {bins},
Observations: {length(cop_usd_trm$trm)}"),
caption = str_glue("Data source: Banco de la República (Colombia) & Superintendencia Financiera de Colombia (SFC)
Last update: {cop_usd_trm$date[length(cop_usd_trm$date)]}")) +
theme(panel.border = element_rect(fill = NA, color = "black"),
plot.background = element_rect(fill = "#f3fcfc"),
panel.background = element_rect(fill = "#f3f7fc"),
legend.background = element_rect(fill = "#f3fcfc"),
plot.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
legend.title = element_text(face = "bold"),
axis.text.x = element_text(face = "bold", angle = 90, vjust = 0.5),
axis.text.y = element_text(face = "bold"))
```
# Analysis of exchange rates
- Visualizing the data
```{r, out.width="80%"}
# Plot
cop_usd_trm %>%
ggplot() +
geom_histogram(aes(x = trm_change),
bins = bins + 1,
color = "black",
fill = palette_light()[[1]],
alpha = 0.8,
boundary = min(cop_usd_trm$trm_change, na.rm = TRUE)) +
scale_x_continuous(labels = scales::number_format(accuracy = 0.01),
breaks = seq(from = min(cop_usd_trm$trm_change, na.rm = TRUE),
to = max(cop_usd_trm$trm_change, na.rm = TRUE),
by = (max(cop_usd_trm$trm_change, na.rm = TRUE) - min(cop_usd_trm$trm_change, na.rm = TRUE)) / bins)) +
labs(x = "",
y = "",
title = "Frequency distribution: daily change MRE COP/USD",
subtitle = str_glue("Period: {cop_usd_trm$date[2]} - {cop_usd_trm$date[length(cop_usd_trm$date)]}
Bins: {bins},
Observations: {length(cop_usd_trm$trm_change[!is.na(cop_usd_trm$trm_change)])}"),
caption = str_glue("Data source: Banco de la República (Colombia) & Superintendencia Financiera de Colombia (SFC)
Last update: {cop_usd_trm$date[length(cop_usd_trm$date)]}")) +
theme(panel.border = element_rect(fill = NA, color = "black"),
plot.background = element_rect(fill = "#f3fcfc"),
panel.background = element_rect(fill = "#f3f7fc"),
legend.background = element_rect(fill = "#f3fcfc"),
plot.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
legend.title = element_text(face = "bold"),
axis.text.x = element_text(face = "bold", angle = 90, vjust = 0.5),
axis.text.y = element_text(face = "bold"))
```
# Analysis of exchange rates
- Visualizing the data
```{r, out.width="80%"}
# Plot
cop_usd_trm %>%
ggplot() +
geom_histogram(aes(x = trm_change, y = ..density..),
bins = bins + 1,
color = "black",
fill = palette_light()[[1]],
alpha = 0.8,
boundary = min(cop_usd_trm$trm_change, na.rm = TRUE)) +
geom_density(aes(x = trm_change),
color = palette_light()[[2]],
size = 0.5,
linetype = "longdash") +
scale_x_continuous(labels = scales::number_format(accuracy = 0.01),
breaks = seq(from = min(cop_usd_trm$trm_change, na.rm = TRUE),
to = max(cop_usd_trm$trm_change, na.rm = TRUE),
by = (max(cop_usd_trm$trm_change, na.rm = TRUE) - min(cop_usd_trm$trm_change, na.rm = TRUE)) / bins)) +
labs(x = "",
y = "",
title = "Empirical probability density function: daily change MRE COP/USD",
subtitle = str_glue("Period: {cop_usd_trm$date[2]} - {cop_usd_trm$date[length(cop_usd_trm$date)]}
Bins: {bins},
Observations: {length(cop_usd_trm$trm_change[!is.na(cop_usd_trm$trm_change)])}"),
caption = str_glue("Data source: Banco de la República (Colombia) & Superintendencia Financiera de Colombia (SFC)
Last update: {cop_usd_trm$date[length(cop_usd_trm$date)]}")) +
theme(panel.border = element_rect(fill = NA, color = "black"),
plot.background = element_rect(fill = "#f3fcfc"),
panel.background = element_rect(fill = "#f3f7fc"),
legend.background = element_rect(fill = "#f3fcfc"),
plot.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
legend.title = element_text(face = "bold"),
axis.text.x = element_text(face = "bold", angle = 90, vjust = 0.5),
axis.text.y = element_text(face = "bold"))
```
# Analysis of exchange rates
- Visualizing the data
```{r, out.width="80%"}
# Data
cop_usd_trm_filter <- cop_usd_trm %>%
filter(trm_change != 0)
# Plot
cop_usd_trm_filter %>%
ggplot() +
geom_histogram(aes(x = trm_change, y = ..density..),
bins = bins + 1,
color = "black",
fill = palette_light()[[1]],
alpha = 0.8,
boundary = min(cop_usd_trm_filter$trm_change, na.rm = TRUE)) +
geom_density(aes(x = trm_change),
color = palette_light()[[2]],
size = 0.5,
linetype = "longdash") +
scale_x_continuous(labels = scales::number_format(accuracy = 0.01),
breaks = seq(from = min(cop_usd_trm_filter$trm_change, na.rm = TRUE),
to = max(cop_usd_trm_filter$trm_change, na.rm = TRUE),
by = (max(cop_usd_trm_filter$trm_change, na.rm = TRUE) - min(cop_usd_trm_filter$trm_change, na.rm = TRUE)) / bins)) +
geom_vline(xintercept = mean(cop_usd_trm_filter$trm_change),
color = palette_light()[[3]],
size = 1) +
geom_segment(data = tibble(x = (mean(cop_usd_trm_filter$trm_change) - sd(cop_usd_trm_filter$trm_change)),
y = 0,
xend = (mean(cop_usd_trm_filter$trm_change) + sd(cop_usd_trm_filter$trm_change)),
yend = 0),
aes(x = x, y = y, xend = xend, yend = yend),
color = palette_light()[[10]],
size = 1) +
labs(x = "",
y = "",
title = str_glue("Empirical probability density function: daily change MRE COP/USD
Excluding observations with daily change equal to zero"),
subtitle = str_glue("Bins: {bins},
Observations: {length(cop_usd_trm_filter$trm_change[!is.na(cop_usd_trm_filter$trm_change)])}"),
caption = str_glue("Data source: Banco de la República (Colombia) & Superintendencia Financiera de Colombia (SFC)
Last update: {cop_usd_trm$date[length(cop_usd_trm$date)]}")) +
annotate(geom = "label",
x = 140.02,
y = 0.06,
label = str_glue("Mean: {mean(cop_usd_trm_filter$trm_change) %>% round(digits = 2)}
Median: {median(cop_usd_trm_filter$trm_change) %>% round(digits = 2)}
Standard deviation: {sd(cop_usd_trm_filter$trm_change) %>% round(digits = 2)}
Coefficient of variation: {(sd(cop_usd_trm_filter$trm_change) / mean(cop_usd_trm_filter$trm_change)) %>% round(digits = 2)}
Skewness: {skewness(cop_usd_trm_filter$trm_change) %>% round(digits = 2)}
Kurtosis: {kurtosis(cop_usd_trm_filter$trm_change) %>% round(digits = 2)}"),
color = "white",
fill = palette_light()[[1]]) +
theme(panel.border = element_rect(fill = NA, color = "black"),
plot.background = element_rect(fill = "#f3fcfc"),
panel.background = element_rect(fill = "#f3f7fc"),
legend.background = element_rect(fill = "#f3fcfc"),
plot.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
legend.title = element_text(face = "bold"),
axis.text.x = element_text(face = "bold", angle = 90, vjust = 0.5),
axis.text.y = element_text(face = "bold"))
```
# Simple model of exchange rate determination
- Decision of an individual between a national and a foreign financial instrument with a low risk
+ Assume you have $100$ COP in $t$
+ __Option 1__: Invest in a national financial instrument with and interest rate $i_t$ in COP
+ __Option 2__: Invest in a foreign financial instrument with and interest rate $i_t^*$ in USD
# Simple model of exchange rate determination
- Decision of individuals between a national and a foreign financial instrument with a low risk
+ Yield obtained in $t + 1$:
+ __Option 1__: $$(1 + i_t) \times 100$$
+ __Option 2__: $$\begin{split}
100 & \rightarrow \frac{100}{E_t} \\
& \rightarrow (1 + i_t^*) \times \frac{100}{E_t} \\
& \rightarrow (1 + i_t^*) \times \frac{100}{E_t} \times E_{t + 1} \\
& \rightarrow (1 + i_t^*) \times 100 \times \frac{E_{t + 1}}{E_t}
\end{split}$$
# Simple model of exchange rate determination
- Decision of an individual between a national and a foreign financial instrument with a low risk
+ $(1 + i_t) \times 100 > (1 + i_t^*) \times 100 \times \frac{E_{t + 1}}{E_t}$ individuals will have only national financial instruments
+ $(1 + i_t) \times 100 < (1 + i_t^*) \times 100 \times \frac{E_{t + 1}}{E_t}$ individuals will have only foreign financial instruments
+ $(1 + i_t) \times 100 = (1 + i_t^*) \times 100 \times \frac{E_{t + 1}}{E_t}$ individuals will have national and foreign financial instruments
+ In an economy individuals have national and foreign financial instruments. Therefore in the long run we have that $(1 + i_t) \times 100 = (1 + i_t^*) \times 100 \times \frac{E_{t + 1}}{E_t}$
# Simple model of exchange rate determination
- Decision of an individual between a national and a foreign financial instrument with a low risk
$$\begin{split}
(1 + i_t) \times 100 & = (1 + i_t^*) \times 100 \times \frac{E_{t + 1}}{E_t} \\
(1 + i_t) & = (1 + i_t^*) \times \frac{E_{t + 1}}{E_t} \\
\frac{(1 + i_t)}{(1 + i_t^*)} \times E_t & = E_{t + 1} \\
E_{t + 1} & = \frac{(1 + i_t)}{(1 + i_t^*)} \times E_t
\end{split}$$
- We can forecast the exchange rate in $t + 1$, $E_{t + 1}$, using information in $t$, $i_t, i_t^*, E_t$
# Simple model of exchange rate determination
- Using $E_{t + 1} = \frac{(1 + i_t)}{(1 + i_t^*)} \times E_t$ to forecast $E_{t + 1}$ 3 months ahead
+ Data
+ 3-month or 90-day rates and yields: Certificates of deposit for Colombia (COLIR3TCD01STM)[^3]
+ 3-Month or 90-day Rates and Yields: Certificates of Deposit for the United States (IR3TCD01USM156N)[^4]
+ Monthly mean Market Representative Exchange Rate (MRE)
+ $t + 1$
+ 3 months later
[^3]: FRED Economic Data | St. Louis FED: https://fred.stlouisfed.org/
[^4]: FRED Economic Data | St. Louis FED: https://fred.stlouisfed.org/
# Simple model of exchange rate determination
- Using $E_{t + 1} = \frac{(1 + i_t)}{(1 + i_t^*)} \times E_t$ to forecast $E_{t + 1}$ 3 months ahead
```{r, out.width="80%"}
# Calculate montly mean trm to convert data into monthly
cop_usd_trm_mean_month <- cop_usd_trm %>%
filter_by_time(.date_var = date,
.start_date = "1991-12-01",
.end_date = floor_date(max(cop_usd_trm$date), unit = "month") %-time% "1 day") %>%
summarize_by_time(.date_var = date,
.by = "month",
value = mean(trm)) %>%
set_names(nm = c("date", "trm_mean_month"))
# Information about interest rates in COL and USA
i_col_usa <- tq_get(x = c("COLIR3TCD01STM", "IR3TCD01USM156N"),
get = "economic.data",
# There is missing data in 2020-04-01 for USA (IR3TCD01USM156N)
from = "1991-12-01") %>%
pivot_wider(id_cols = date,
names_from = symbol,
values_from = price) %>%
set_names(nm = c("date", "i_col", "i_usa"))
# Joining data about trm COP/USA and interest rates in COL and USA
i_col_usa_trm <- i_col_usa %>%
left_join(y = cop_usd_trm_mean_month,
by = "date") %>%
# Expressing interest rates without percent
mutate(i_col = i_col / 100,
i_usa = i_usa / 100)
# Comparing forecasts with actual values
i_col_usa_trm_forecast <- i_col_usa_trm %>%
mutate(trm_forecast_3_month = ((1 + i_col) / (1 + i_usa)) * trm_mean_month) %>%
select(date, trm_forecast_3_month) %>%
mutate(date = date %m+% period("3 months")) %>%
left_join(i_col_usa_trm, by = "date") %>%
select(date, trm_mean_month, trm_forecast_3_month) %>%
# Dropping forecasts because I don't nothing to compare with
drop_na() %>%
mutate(error = abs(trm_mean_month - trm_forecast_3_month))
# Plot
# Data
clean_data <- i_col_usa_trm_forecast %>%
select(date, trm_mean_month, trm_forecast_3_month) %>%
pivot_longer(cols = trm_mean_month:trm_forecast_3_month) %>%
mutate(name = case_when(
name == "trm_mean_month" ~ "Actual value",
name == "trm_forecast_3_month" ~ "Forecast",
.default = as.character(name)),
date = ceiling_date(date, unit = "month") %-time% "1 day")
# Clean plot
clean_data %>%
ggplot() +
geom_line(aes(x = date,
y = value,
group = name,
color = name)) +
scale_color_tq() +
labs(x = "",
y = "COP/USD",
color = "",
title = "Forecasting Monthly mean Market Representative Exchange Rate (MRE)",
subtitle = str_glue("Period: {clean_data$date[1]} - {clean_data$date[length(clean_data$date)]},
Observations: {length(clean_data$date) / 2}")) +
theme(panel.border = element_rect(fill = NA, color = "black"),
plot.background = element_rect(fill = "#f3fcfc"),
panel.background = element_rect(fill = "#f3f7fc"),
legend.background = element_rect(fill = "#f3fcfc"),
plot.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
legend.title = element_text(face = "bold"),
legend.position = "bottom",
axis.text = element_text(face = "bold"))
```
# Simple model of exchange rate determination
- Forecast error: $|\text{Actual value - Forecast}|$
```{r, out.width="80%"}
i_col_usa_trm_forecast %>%
ggplot() +
geom_histogram(aes(x = error, y = after_stat(density)),
bins = bins + 1,
color = "black",
fill = palette_light()[[1]],
alpha = 0.8,
boundary = min(i_col_usa_trm_forecast$error)) +
geom_density(aes(x = error),
color = palette_light()[[2]],
size = 0.5,
linetype = "longdash") +
scale_x_continuous(labels = scales::number_format(accuracy = 0.01),
breaks = seq(from = min(i_col_usa_trm_forecast$error),
to = max(i_col_usa_trm_forecast$error),
by = (max(i_col_usa_trm_forecast$error) - min(i_col_usa_trm_forecast$error)) / bins)) +
geom_vline(xintercept = mean(i_col_usa_trm_forecast$error),
color = palette_light()[[3]],
size = 1) +
geom_segment(data = tibble(x = (mean(i_col_usa_trm_forecast$error) - sd(i_col_usa_trm_forecast$error)),
y = 0,
xend = (mean(i_col_usa_trm_forecast$error) + sd(i_col_usa_trm_forecast$error)),
yend = 0),
aes(x = x, y = y, xend = xend, yend = yend),
color = palette_light()[[10]],
size = 1) +
labs(x = "",
y = "",
title = "Frequency distribution: forecasting error",
subtitle = str_glue("Period: {i_col_usa_trm_forecast$date[1]} - {i_col_usa_trm_forecast$date[length(i_col_usa_trm_forecast$date)]},
Observations: {length(i_col_usa_trm_forecast$date)}
Bins: {bins}")) +
annotate(geom = "label",
x = 450,
y = 0.003,
label = str_glue("Mean: {mean(i_col_usa_trm_forecast$error) %>% round(digits = 2)}
Median: {median(i_col_usa_trm_forecast$error) %>% round(digits = 2)}
Standard deviation: {sd(i_col_usa_trm_forecast$error) %>% round(digits = 2)}
Coefficient of variation: {(sd(i_col_usa_trm_forecast$error) / mean(i_col_usa_trm_forecast$error)) %>% round(digits = 2)}
Skewness: {skewness(i_col_usa_trm_forecast$error) %>% round(digits = 2)}
Kurtosis: {kurtosis(i_col_usa_trm_forecast$error) %>% round(digits = 2)}"),
color = "white",
fill = palette_light()[[1]]) +
theme(panel.border = element_rect(fill = NA, color = "black"),
plot.background = element_rect(fill = "#f3fcfc"),
panel.background = element_rect(fill = "#f3f7fc"),
legend.background = element_rect(fill = "#f3fcfc"),
plot.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
legend.title = element_text(face = "bold"),
axis.text.x = element_text(face = "bold", angle = 90, vjust = 0.5),
axis.text.y = element_text(face = "bold"))
```
# Implicit devaluation
- A possible way to calculate the implicit devaluation:
$$\begin{split}
\text{Implicit devaluation} & = E_{t + 1} - E_t \\
& = \frac{(1 + i_t)}{(1 + i_t^*)} \times E_t - E_t \\
& = \bigg[ \frac{(1 + i_t)}{(1 + i_t^*)} - 1 \bigg] \times E_t \\
& = \bigg[ \frac{i_t - i_t^*}{1 + i_t^*} \bigg] \times E_t
\end{split}$$
# Acknowledgments
- To my family that supports me
- To the taxpayers of Colombia and the __[UMNG students](https://www.umng.edu.co/estudiante)__ who pay my salary
- To the __[Business Science](https://www.business-science.io/)__ and __[R4DS Online Learning](https://www.rfordatasci.com/)__ communities where I learn __[R](https://www.r-project.org/about.html)__
- To the __[R Core Team](https://www.r-project.org/contributors.html)__, the creators of __[RStudio IDE](https://rstudio.com/products/rstudio/)__ and the authors and maintainers of the packages __[tidyverse](https://CRAN.R-project.org/package=tidyverse)__, __[lubridate](https://CRAN.R-project.org/package=lubridate)__, __[tidyquant](https://CRAN.R-project.org/package=tidyquant)__, __[moments](https://CRAN.R-project.org/package=moments)__, __[timetk](https://CRAN.R-project.org/package=timetk)__ and __[tinytex](https://CRAN.R-project.org/package=tinytex)__ for allowing me to access these tools without paying for a license
- To the __[Linux kernel community](https://www.kernel.org/category/about.html)__ for allowing me the possibility to use some __[Linux distributions](https://static.lwn.net/Distributions/)__ as my main __[OS](https://en.wikipedia.org/wiki/Operating_system)__ without paying for a license
# References