Modeling Default Correlations

Overview


Maximum Likelihood

Likelihood Multiple Sectors


{% L_t = \int_{- \infty}^{\infty} \Pi_{k=1}^{\infty} \binom{N_{kt}}{D_{kt}} p_k(Z)^{D_{kt}} (1-p_k(Z))^{N_{kt} - D_{kt}} d \Phi(Z) %}
{% L = \Pi_{t=1}^T \int_{- \infty}^{\infty} \Pi_{k=1}^{\infty} \binom{N_{kt}}{D_{kt}} p_k(Z)^{D_{kt}} (1-p_k(Z))^{N_{kt} - D_{kt}} d \Phi(Z) %}

Numeric Integrand Approximation


We express the integrand above in the following form.
{% exp[\sum_{k} (log(\binom{N_{kt}}{D_{kt}}) + D_{kt} log(p_k(Z)) + (N_{kt} - D_{kt}) log(1-p_k(Z)))] %}
This is done because of numeric issues with calculating the number of combinations for a large number of loans. Here, we have converted the combinations to the logarithm of the number of combinations for which there is a numeric approximation.

Implementation


The data is encoded similar to the case of a single sector. However, each data point will include an array that contains the data for each sector.

The following code shows data for two time periods and two different sectors.


let data = [
	[[1064,0],[321,2]],
	[[1465,2],[589,65]]
];
					
The integrand is now different.


let getIntegrand = function(point, p, w){
	return function(x){
        let sum = 0;
        for(let i=0;i<point.length;i++){
            let Nk = point[i][0];
            let Dk = point[i][1];
            let lnCombinations = ml.lncombin(Nk,Dk);
            sum += lnCombinations;
            let prob = ml.conditionalProbability(x,p[i],w[i]);
            sum += Dk * Math.log(prob);
            sum += (Nk-Dk)*Math.log(1-prob);
        }
        return Math.exp(sum);
	}
}
					
Try it!


let ml = await import('/lib/finance/credit/v1.0.0/maximum-likelihood.mjs');
    
let p = [0.00137, 0.0445];
let w = [0.2668, 0.3271];

let data = [
	[[1064,0],[321,2]],
	[[1465,2],[589,65]],
    [[1617,0],[526,32]],
    [[3398,14],[2528,88]],
];

let result = ml.logLikelihood(data, p, w);
					
Try it!

Contents