Leverage R Code within .Net Environments (Running a CVaR Model in C# Applications)

Introduction

A nifty .NET library, ‘R.NET‘, allows you to leverage previously written R scripts within your C# and other .NET applications. Experienced model developers often end up accumulating extremely useful R scripts which have been optimized to perform specific tasks. When you have a library of codes that you trust to perform operations as you expect, the knowledge that you can re-use the codes regardless of the development platform is invaluable. This is one of the benefits R.NET provides.

R.NET is just one of several method you can use to establish an interface between C# (.NET). The advantage of R. R.NET is that it enables the .NET Framework to ‘interoperate’ with the R statistical language in the same process (this is important because it prevents bulky code) . Also, the syntax is simple enough that anyone who has a little experience with both R and .NET products can pretty easily use it.Read More »

Use R to Easily Estimate Migration Matrices with RTransProb (Part 1)

This blog introduces my R package, RTransprob. The RTransprob package contains a set of functions used to automate commonly used methods to estimate migration matrices used in credit risk analysis. This includes methods for estimating migration and default rates based on the duration and cohort methods, bootstrapping default rates and forecasting/stress testing credit exposures migrations, via Econometrics and a couple of Machine Learning algorithms.

Read More »

Turbo charge your R code with RCPP

So, you’ve written code in R which contains somewhat complicated loops. The execution time is not quite as fast as you hoped for. You turn to using the profvis package in RStudio (or Rprof) to profile the R program, in the hopes of finding the places in your code that are causing the bottleneck.  The profiler returns a few areas that you focus on to make more efficient, but unfortunately no matter how many ‘loops’ you jump through, you can’t seem to reduce the execution time.

Next, you spend at least a couple of frustrating hours trying to figure out how to vectorize (think: higher-level programming to improve efficiency) the loops creating the bottleneck, to no avail. And it’s okay to admit it, we’ve all been there.

STOP!!!! The solution may be to rewrite some of your key functions in C++.Read More »

How to quantify Model Risk from Parameter Uncertainty

For a quantitative analyst whose models are frequently scrutinized by Federal Reserve Bank examiners, the ability to quantify model risk is an important part of the model documentation process. Model risk is typically described as “. . . the potential for adverse consequences from decisions based on incorrect or misused model outputs and reports.”

Model Risk quantification can be a tricky concept to grasp.  But when we consider that models are nothing more than abstractions of real life situations, it’s easier to see how there are risks associated with models. Even when models perform exceptionally well in recreating said real life scenario.Read More »