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

# Author Archive for A Quant in Canada

# 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,…

# Upper Bound for RER under VaR

In continuation of some previous posts on residual estimation risk (RER), we establish an upper bound for RER when the risk measure is VaR for any arbitrary error distribution , where the error distribution is defined as the difference between an actual loss distribution and a loss estimator (see [1] for more details). Asymmetric Error Distribution For an arbitrary…

# Sensitivities for Make-whole Callable Bonds

A callable bond is a bond that provides the issuer with the right to exchange the bond for its call value in cash. There are a few ways one can value a callable bond by extending the expression of a vanilla bond: Yield-to-x: Calculate the yield-to-maturity, yield(s)-to-call, and/or yield-to-worst and take the lowest of this set. Revalue the bond with…

# 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…