AppPresentation

GuAR
2020/09/23

Describing the App

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:

  • A date range. The oldest date available is January 31, 2011 and the most recent date is August 31, 2020. The user must select end of month dates, otherwise the model results do not update. In financial literature, it is advised to calculate betas (sensitivities) using a five-year period
  • A currency. The featured currencies include: AUD - Australian dollar, BRL - Brazilian Real, CAD - Canadian dollar, CNY - Chinese Yuan, DKK - Danish Krone, EUR - Euro, GBP - British Pound, HKD - Hong Kong dollar, INR - Indian Rupee, JPY - Japanese Yen, MYR - Malaysian Ringgit, MXN - Mexican Peso, NOK - Norwegian Krone, ZAR - South African Rand, SGD - Singapore dollar, KRW - South Korean Won, LKR - Sri Lankan Rupee, SEK - Swedish Krona, CHF - Swiss Franc, TWD - New Taiwan dollar, THB - Thai Baht
  • A US Dollar Index. The featured indexes are calculated by the US Federal Reserve and include: a broad US Dollar Index, an Advanced Foreign Economies Dollar Index, and an Emerging Economies Dollar Index

All the data used is publicly available at: https://www.federalreserve.gov/

Describing the App

Once the user has provided the necessary inputs, the App estimates a linear model and shows all the following results in a plot:

  • Scatter plot. Plots all the points where the x-axis is given by the selected US Dollar Index, and the y-axis is given by the selected currency. Each point in the plot corresponds to a month in the date range selected by the user
  • Regression line. The line exhibits the predicted values for each x-value in the dataset
  • Alpha and Beta estimates. The alpha and beta values estimated by the univariate linear model are shown in red. The Beta estimate can be interpreted as the sensitivity of a currency to the selected US Dollar Index; while the alpha estimate represents a portion of the currency monthly returns that cannot be explained by its exposure to “market” movements.

A beta estimate greater than 1 indicates that the selected currency is more sensitive to movements of the selected US Dollar index.

App Code

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))

App Output

plot of chunk unnamed-chunk-2