I'm using various matrices to impute a fitted transition matrix for credit ratings by solving for a variable [S]. Essentially the idea is to determine a base matrix and stress matrix to compare to a single point of time [t1] to create a fitted transition matrix [t1 fitted]. With the data below, [t1 fitted] and [t1 variance] is derived from the following formula:
[t1 fitted] = (1-S)*[Base Matrix] + S*[Stress Matrix]
[t1 variance] = ([t1] - [t1 fitted])^2
I would like to know how or a direction I can take to solve for this [S] variable where the sum of [t1 variance] is the lowest value. I'd appreciate any direction or solution (functions to use or sample code) as I am not too familiar with R functions/packages and simply recreating the approach as a challenge of the results.
Thanks for your time.
Solution from the sample data below where I derived it using Excel's Solver function by using the GRG Nonlinear method solving for the min value of [S]. (Excel document can be provided if necessary)
[S]=41.8962055525792%
sum[t1 variance]=2.56220853052315%
****************************** Base Matrix (t1-t4) ******************************
From/To: AAA AA A BBB BB B CCC Default
AAA 91.90% 7.39% 0.72% 0.00% 0.00% 0.00% 0.00% 0.00%
AA 1.13% 91.26% 7.09% 0.31% 0.21% 0.00% 0.00% 0.00%
A 0.10% 2.56% 91.19% 5.33% 0.62% 0.21% 0.00% 0.00%
BBB 0.00% 0.21% 5.36% 87.94% 5.46% 0.83% 0.10% 0.10%
BB 0.00% 0.11% 0.43% 5.00% 85.12% 7.33% 0.43% 1.59%
B 0.00% 0.11% 0.11% 0.54% 5.97% 82.19% 2.17% 8.90%
CCC 0.00% 0.44% 0.44% 0.87% 2.51% 5.90% 67.80% 22.05%
Default 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 100.00%
******************************* Stress Matrix (t2) ******************************
From/To: AAA AA A BBB BB B CCC Default
AAA 90.79% 8.29% 0.72% 0.10% 0.10% 0.00% 0.00% 0.00%
AA 0.10% 91.22% 7.85% 0.62% 0.10% 0.10% 0.00% 0.00%
A 0.92% 2.36% 90.04% 5.44% 0.72% 0.31% 0.10% 0.10%
BBB 0.00% 0.32% 5.94% 86.95% 5.30% 1.17% 0.12% 0.21%
BB 0.00% 0.11% 0.66% 7.69% 80.55% 8.79% 0.99% 1.21%
B 0.00% 0.11% 0.23% 0.45% 6.47% 82.75% 4.09% 5.90%
CCC 0.23% 0.00% 0.23% 1.25% 2.28% 12.86% 60.64% 22.53%
Default 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 100.00%
*********************************** t1 Matrix ***********************************
From/To: AAA AA A BBB BB B CCC Default
AAA 94.16% 5.84% 0.00% 0.00% 0.00% 0.00% 0.00% 0.00%
AA 4.56% 90.89% 4.34% 0.11% 0.00% 0.11% 0.00% 0.00%
A 0.00% 10.10% 87.04% 2.67% 0.06% 0.00% 0.13% 0.00%
BBB 0.00% 0.19% 7.42% 88.44% 3.67% 0.28% 0.00% 0.00%
BB 0.00% 0.00% 0.19% 8.25% 83.49% 7.32% 0.75% 0.00%
B 0.10% 0.00% 0.00% 0.20% 6.54% 83.71% 9.46% 0.00%
CCC 0.00% 0.00% 0.00% 0.00% 0.00% 8.13% 68.62% 23.25%
Default 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 100.00%
******************************** t1 Fitted Matrix *******************************
From/To: AAA AA A BBB BB B CCC Default
AAA 91.43% 7.76% 0.72% 0.04% 0.04% 0.00% 0.00% 0.00%
AA 0.70% 91.25% 7.41% 0.44% 0.16% 0.04% 0.00% 0.00%
A 0.45% 2.48% 90.71% 5.38% 0.66% 0.25% 0.04% 0.04%
BBB 0.00% 0.25% 5.60% 87.52% 5.40% 0.97% 0.11% 0.15%
BB 0.00% 0.11% 0.52% 6.12% 83.21% 7.94% 0.66% 1.43%
B 0.00% 0.11% 0.16% 0.51% 6.18% 82.43% 2.97% 7.65%
CCC 0.10% 0.25% 0.35% 1.03% 2.41% 8.81% 64.80% 22.25%
Default 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 100.00%
******************************* t1 Variance Matrix ******************************
From/To: AAA AA A BBB BB B CCC Default
AAA 0.07% 0.04% 0.01% 0.00% 0.00% 0.00% 0.00% 0.00%
AA 0.15% 0.00% 0.09% 0.00% 0.00% 0.00% 0.00% 0.00%
A 0.00% 0.58% 0.13% 0.07% 0.00% 0.00% 0.00% 0.00%
BBB 0.00% 0.00% 0.03% 0.01% 0.03% 0.00% 0.00% 0.00%
BB 0.00% 0.00% 0.00% 0.05% 0.00% 0.00% 0.00% 0.02%
B 0.00% 0.00% 0.00% 0.00% 0.00% 0.02% 0.42% 0.58%
CCC 0.00% 0.00% 0.00% 0.01% 0.06% 0.00% 0.15% 0.01%
Default 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.00% 0.00%