Modeling Default Correlations

Overview


Maximum Likelihood

Likelihood One Sector


{% L_{kt} = \int_{- \infty}^{\infty} \binom{N_{kt}}{D_{kt}} p_k(Z)^{D_{kt}} (1-p_k(Z))^{N_{kt} - D_{kt}} d \Phi(Z) %}
where the integral here is a Riemann Stieltjes Integral.

Here
{% d\Phi = \sqrt{1/2\pi \sigma^2 } \times e ^{-0.5 [(x-\mu)/\sigma]^2} dx %}


This integral can be approximated using the Gauss Hermite Quadrature



The Likelihood over the entire time period is given by
{% L_k = \Pi_{t=1}^T L_{kt} %}
{% ln L_k = \sum_{t=1}^T ln \int_{- \infty}^{\infty} \binom{N_{kt}}{D_{kt}} p_k(Z)^{D_{kt}} (1-p_k(Z))^{N_{kt} - D_{kt}} d \Phi(Z) %}

Likelihood One Sector


We encode the data as an array of sample points. Each sample point is an array where the first number represents {% N_{kt} %} and the second number is {% D_{kt} %}. Each data point represents a separate point in time.


let data = [
	[1064,0],
	[1327,2],
];
					
For a given time point, and a given value of {% p %} and {% w %}, we need to construct a function which computes
{% \binom{N_{kt}}{D_{kt}} p_k(Z)^{D_{kt}} (1-p_k(Z))^{N_{kt} - D_{kt}} %}
The following code implements this.


let cb = await import('/lib/combinatorics/v1.0.0/combinatorics.mjs');

let getIntegrand = function(N, D, p, w){
  return function(x){
    let combinations = cb.combinations(N,D);
    let condProb = ml.conditionalProbability(x,p,w);
    return combinations * Math.pow(condProb, D) * Math.pow(1-condProb,N-D);
  }
}
					
Next, we need to compute the given integral, take the logarithm and then sum.


let sum = 0;
for(let item of data){
  let integrand = getIntegrand(item[0], item[1],p,w);
  let integral = ml.gaussHermite(integrand);
  let logLike1 = Math.log(integral);
  sum+=logLike1;
}
					
Try it!

Contents