GuAR
2020/09/23
Our App aims at estimating the sensitivity of 22 different currencies to a US Dollar Index. The sensitivity of a currency is given by the beta estimated by a linear regression model where the response variable is the monthly returns data series of the currency of interest and the explanatory variable is the US Dollar Index selected. The user must share three different inputs:
All the data used is publicly available at: https://www.federalreserve.gov/
Once the user has provided the necessary inputs, the App estimates a linear model and shows all the following results in a plot:
A beta estimate greater than 1 indicates that the selected currency is more sensitive to movements of the selected US Dollar index.
Once the user loads the necessary inputs, the App estimates the univariate linear regression model and generates the resulting plot. An example using MXN as the currency, Emerging Markets Dollar Index as index, and dates ranging from 31/07/2015 to 31/08/2020 generate the following output:
library(lubridate)
library(dplyr)
library(ggplot2)
db <- read.csv("Currencies.csv")
db$MonthBeg <- paste(db$MonthDate,"-01", sep="")
db$MonthDateNum <- as.Date(db$MonthBeg, format="%Y-%m-%d")
db$MonthEnd <- db$MonthDateNum + months(1) - days(1)
currlist <- names(db)[2:23]
indexlist <- names(db)[24:26]
begdate <- as.Date("2015-07-31",format("%Y-%m-%d"))
enddate <- as.Date("2020-08-31",format("%Y-%m-%d"))
currsym <- "MXN"
indexsym <- "Emerging_Markets_Index"
colvec <- c(which(names(db) == currsym),which(names(db) == indexsym), 29)
dbbeta <- db[db$MonthEnd>=begdate & db$MonthEnd <= enddate,colvec]
modfit <- lm(dbbeta[,currsym] ~ dbbeta[,indexsym])
ggplot(dbbeta, aes(x=dbbeta[,indexsym], y=dbbeta[,currsym])) +
geom_point(shape=1) +
geom_smooth(method=lm,se=FALSE) +
geom_line(aes(y = predict(modfit)), col="red") +
annotate(geom="text", x=0, y=2, label=paste("alpha=",
as.character(round(modfit$coefficients[1],4)),"; beta=",
as.character(round(modfit$coefficients[2],4))),
color="red")+
ggtitle(paste(currsym, "Sensitivity to", indexsym)) +
xlab(paste("Monthly Returns (%) of",indexsym)) +
ylab(paste("Monthly Returns (%) of", currsym))