Visualizing ROC Curves in R using Plotly

In this post we’ll create some simple functions to generate and chart a Receiver Operator (ROC) curve and visualize it using Plotly. See Carson’s plotly book for more details around changes in syntax.

We’ll do this from a credit risk perspective i.e. validating a bank’s internal rating model (we’ll create a sample dataset keeping this in mind)

We’ll replicate computations highlighted in this paper.

Sample data

ROC Curve Computation

Now that we have a sample dataset to work with we can start to create the ROC curve

Plot