Arguably one of Yahoo's most valuable assets, aside from its stake in BABA, was it's finance website. Few sites, including Google, have such readily (freely) accessible and easily digestible financial information on US equities than Yahoo does. Of course, for the financially sophisticated there are far superior sites that have advanced charting platforms and useful visualizations (TradingView and FinViz come to mind),…

# R

# Parallelism for Model Training (using the caret package)

In a previous post we discussed how to achieve parallel programming in R using the doParallel package. This post provides an application of parallelism for training a model using the caret package. We use repeated cross validation to train a support vector machine (note the iris data is small and doesn't require such exhaustive training; it was merely used for…

# Risk Factor Back-Testing

P&L exceeding VaR limits is not an uncommon phenomenon. In fact, (accurate) VaR models should be designed such that there is some expectation of P&L exceeding the VaR (the number of breaches being proportionate to the level of confidence). However, in practice, whenever P&L exceeds VaR it is prudent to investigate why the breach has occurred. For OSFI-regulated financial institutions,…

# Residual Estimation Risk

My 3-month hiatus has ended thanks to the Canadian long weekend. In these past few months I haven't had much time time to commit to posting new content, primarily because I started a new job. This has put my research interests on hold for the time being. So while I will likely not post as frequently as I have in…

# Some Simple Measures of Correlation

To implement the following measures of correlation, we use the ‘wine’ dataset from the HDclassif package. To wet your palate, we test for correlation between ‘alcohol’ and ‘proline’ (an amino acid) content. Note that we employ the correlation measure tests from the psych, rather than base package. Pearson’s Rho Correlation The Pearson correlation coefficient is a measure of the linear…

# Some Simple Measures of Forecast Accuracy

So you've built a model, the predictive plots look nice, but you want to synthesize this information down to a number. This is where measures of forecast accuracy come in. In this post we will recall some simple measures of forecast accuracy, and then I'll explain why I don't like them, unless you intend to use them to compare more…

# Lévy Processes For Finance: An Introduction In R

Prior to "opting for the herd" and leaving academia to work in the private sector, I began scribbling the details of what my PhD thesis might look like. The topic I was interested in writing my thesis on (at the time) was Lévy processes and in particular their applications to derivatives pricing. I began coding some of the more well-known…

# Numerical Mellin and Two-Sided Laplace Inversion

There are only a handful of methods for numerical Mellin (or equivalently, two-sided Laplace) inversion that have survived due to their computational accuracy and efficiency. One of these such methods is accredited to Dishon and Weiss [1]. The method is quite accurate despite being a numerical approximation and requiring the evaluation of an infinite series. We implement example 1 in…

# Stock Charting Platform in Shiny

Shiny has been available for some time now, but I've only recently had the opportunity to play around with it. For us R users who are constantly purporting the benefits of the language, Shiny is another point to add to the list. Below I've created a simple stock charting application that pulls data from Yahoo's server, then presents the historical…

# Beta Regression Modelling

It is known that the distribution of LGD, EAD, FUC, or CCF (see for the definitions of CCF and FUC) when capped between 0 and 1 exhibits a non-normal shape with bimodal peaks (near 0 and 1). Hence, it is common to use a logistic link function to achieve a unimodal distribution close to normal, prior to running a regression.…