Joint Probability of Default

Overview

The joint rate of default in a given period is given by
{% \frac{D_t(D_t -1)}{N_t(N_t -1)} %}
where {% D %} is the number of defaults in the period, and {% N %} is the total number of loans outstanding. (see joint probability of default) The average joint rate of default is just the average of this number over the periods in the history.

Script

The joint_rate function found in the estimate script, calculates the average joint rate as defined above.

def joint_rate(data): fdata = filter(data) grouped = defaultdict(list) for item in fdata: grouped[item['date']].append(item) list1 = [] for key in grouped: record = { 'D':sum(item["default"] for item in grouped[key]), 'N':len(grouped[key]), 'rate':sum(item["default"] for item in grouped[key])/len(grouped[key]), 'date':key } list1.append(record) average = sum(item["D"]/item['N'] for item in list1) / len(list1) return average

Bootstrapping the Joint PD

The statistical method bootstrapping can be used to calculate a confidence interval around the computed value of the joint probability of default.

import numpy as np from scipy.stats import bootstrap rates = map(lambda x: x['rate'], list1) # Sample dataset data = (np.array(rates),) # Calculate 95% confidence interval for the mean res = bootstrap(data, np.mean, confidence_level=0.95, method='percentile') print("Confidence Interval Lower:", res.confidence_interval.low) print("Confidence Interval Upper:", res.confidence_interval.high)