Making a transition matrix monotonic

40 Views Asked by At

I have transition matrices containing ratings that I need to make monotonic. The counts need to decrease monotonically either side of the diagonal.

I have tried using SAS, but without access to IML I am struggling to make this work. Even with IML I don't know if SAS has enough matrix functionality to do this. I'm not an experienced R user so a detailed answer would be very appreciated! Hopefully there is an R package that the solution is based on.

Below is an example matrix I'm using for testing. Once I have a monotonic matrix I will calculate percentages where each row sums to 1 (or do this first if easier). An issue I found in my SAS attempt is when a newly averaged pairs of values are still not monotonic when considering an adjacent value, and extra loops are then required (such as row 1 of example matrix).

TM_raw_count <- matrix(c(10, 4, 3, 6, 2, 1, 3, 5, 3, 2, 3, 1, 1, 2, 4, 3, 1, 1, 1, 1, 2, 3, 2, 3, 0, 1, 2, 3, 4, 2, 0, 1, 2, 4, 2, 4), nrow = 6, ncol = 6, byrow = TRUE)

Below tables show Raw matrix, and desired processed matrix.

Raw matrix Processed matrix

I have found published papers where this method is used, but the maths is beyond me for R programming: https://www.risk.net/journal-of-risk-model-validation/5587081/smoothing-algorithms-by-constrained-maximum-likelihood-methodologies-and-implementations-for-comprehensive-capital-analysis-and-review-stress-testing-and-international-financial-reporting-standard-9-expected

0

There are 0 best solutions below