Ariel E. Meilij
October 28, 2016
It is a widely accepted fact among economists that the Colombian Peso exchange rate is tied to the prices of WTI and Brent oil barril, given the country's large oil industry. Analyst and traders follow complicated statistical models in order to judge the volatility of the peso (COP) and play the forex market. Within my studies, I have tracked the correlation of the Colombian Peso to the international prices of WTI (West Texas) and Brent oil. It is easier to predict the future value of the Colombian Peso (forex symbol COP) with the prices of oil because currency tends to be much more volatile and in the case of Colombia, it is the inflows of oil trading that peg the COP to the US dollar, not the other way around.
The Shiny application works via a tabbed view where the user can input her or his forecast of WTI and Brent pil barril, and get predictions with updated Machine Learning models of the currency exchange of the Colombian peso using three models:
Note: The training and testing data are accurate up to March 2016.
inTrain <- createDataPartition(y = oilvscop$forex, p = 0.7, list = FALSE)
training <- oilvscop[inTrain, ]
testing <- oilvscop[-inTrain, ]
model1 <- train(forex ~ wti, data = oilvscop, method = "glm")
model2 <- train(forex ~ brent, data = oilvscop, method = "glm")
model3 <- train(forex ~ wti * brent, data = oilvscop, method = "glm")
# Build prediction models plots with updated testing sets
p1 = qplot(testing$forex, predict(model1, testing), colour = forex, data = testing) + geom_smooth(method = "lm") +
xlab("Real Forex Value") + ylab("FOREX WTI prediction")
p2 = qplot(testing$forex, predict(model2, testing), colour = forex, data = testing) + geom_smooth(method = "lm") +
xlab("Real Forex Value") + ylab("FOREX Brent prediction")
p3 = qplot(testing$forex, predict(model3, testing), colour = forex, data = testing) + geom_smooth(method = "lm") +
xlab("Real Forex Value") + ylab("FOREX Composite prediction")
plot_grid(p1, p2, p3, align='h')