# portfolioECL

Compute the lifetime ECL at individual or portfolio level

## Description

example

[totalECL,ECLByID,ECLByPeriod] = portfolioECL(MarginalPD,LGD,EAD), given the MarginalPD, LGD, and EAD values for a portfolio of loans, computes the lifetime expected credit loss (ECL) at the individual or portfolio level.

example

[totalECL,ECLByID,ECLByPeriod] = portfolioECL(___,Name=Value) adds optional name-value pair arguments for ScenarioProbabilities, InterestRate, Periodicity, IDVar, and ScenarioNames.

## Examples

collapse all

This example shows how to calculate the expected credit loss (ECL) based on marginal probability of default (PD), loss given default (LGD), and exposure at default (EAD).

• Marginal PD Expectation of a credit default event over a given time frame.

• LGD — Portion of a nonrecovered credit in the case of default.

• EAD — Balance at the time of default.

IFRS 9 requires multiple economic scenarios to be modeled while computing ECL. This example considers five macroeconomic scenarios: severe, adverse, baseline, favorable, and excellent.

Load the credit data for company IDs 1304 and 2067 and the associated macroeconomic scenarios.

disp(LoanData)
ID      ScoreGroup      YOB    Year
____    _____________    ___    ____

1304    "Medium Risk"     4     2020
1304    "Medium Risk"     5     2021
1304    "Medium Risk"     6     2022
1304    "Medium Risk"     7     2023
1304    "Medium Risk"     8     2024
1304    "Medium Risk"     9     2025
1304    "Medium Risk"    10     2026
2067    "Low Risk"        7     2020
2067    "Low Risk"        8     2021
2067    "Low Risk"        9     2022
2067    "Low Risk"       10     2023
ScenarioID    Year    GDP     Market
__________    ____    ____    ______

"Severe"      2020    -0.9     -5.5
"Severe"      2021    -0.5     -6.5
"Severe"      2022     0.2       -1
"Severe"      2023     0.8      1.5
"Severe"      2024     1.4        4
"Severe"      2025     1.8      6.5
"Severe"      2026     1.8      6.5
"Severe"      2027     1.8      6.5
disp(ScenarioProbabilities)
Probability
___________

Severe           0.1
Baseline         0.3
Favorable        0.2
Excellent        0.2

Load the pdModel that was created using fitLifetimePDModel with a Probit model.

disp(pdModel)
Probit with properties:

ModelID: "Champion"
Description: "A sample model used as champion model for illustration purposes."
Model: [1x1 classreg.regr.CompactGeneralizedLinearModel]
IDVar: "ID"
AgeVar: "YOB"
LoanVars: "ScoreGroup"
MacroVars: ["GDP"    "Market"]
ResponseVar: "Default"

Define the interest rate to discount future losses back to present.

EffRate = 0.045;

Create Scenarios

Compute marginal lifetime PDs for the two companies.

CompanyID = 1304;
IndCompany = LoanData.ID == CompanyID;
Years = LoanData.Year(IndCompany);
NumYears = length(Years);

ScenarioID = unique(MultipleScenarios.ScenarioID,'stable');
NumScenarios = length(ScenarioID);

PD1 = zeros(NumYears,NumScenarios);
for ii=1:NumScenarios
IndScenario = MultipleScenarios.ScenarioID==ScenarioID(ii);
data = join(LoanData(IndCompany,:),MultipleScenarios(IndScenario,:));
end

DiscTimes = Years-Years(1)+1;
DiscFactors = 1./(1+EffRate).^DiscTimes;

ProbScenario = ScenarioProbabilities.Probability;

CompanyID = 2067;
IndCompany = LoanData.ID == CompanyID;
Years = LoanData.Year(IndCompany);
NumYears = length(Years);

PD4 = zeros(NumYears,NumScenarios);
for ii=1:NumScenarios
IndScenario = MultipleScenarios.ScenarioID==ScenarioID(ii);
data = join(LoanData(IndCompany,:),MultipleScenarios(IndScenario,:));
end

Calculate Marginal PD for Multiple IDs

Create a table for the portfolio PD that contains the PD for the two companies.

PD = array2table([PD1; PD4]);
PD.ID = [repmat(1304,7,1);repmat(2067,4,1)];
PD = movevars(PD, 'ID', 'Before', 'Severe');
disp(PD)
ID       Severe       Adverse       Baseline     Favorable     Excellent
____    __________    __________    __________    __________    __________

1304      0.011316     0.0096361     0.0081783      0.006918     0.0058324
1304     0.0078277     0.0069482     0.0061554     0.0054425     0.0048028
1304     0.0048869     0.0044693     0.0040823     0.0037243     0.0033938
1304     0.0031017     0.0029321     0.0027698     0.0026147     0.0024668
1304     0.0019309     0.0018923     0.0018538     0.0018153      0.001777
1304     0.0012157     0.0012197     0.0012233     0.0012264     0.0012293
1304    0.00082053    0.00082322    0.00082562    0.00082775    0.00082964
2067     0.0022199      0.001832     0.0015067      0.001235     0.0010088
2067     0.0014464     0.0012534     0.0010841    0.00093599    0.00080662
2067     0.0008343    0.00074897    0.00067168    0.00060175    0.00053857
2067    0.00049107    0.00045839    0.00042769    0.00039887    0.00037183

Calculate LGD for Multiple IDs

Create a table for the portfolio LGD that contains the LGD for the two companies.

LGD = array2table([0.25, 0.23, 0.21, 0.19, 0.17; 0.24, 0.22, 0.2, 0.18, 0.16]);
LGD.Properties.VariableNames = {'S1','S2','S3','S4','S5'};
LGD.ID = [1304;2067];
LGD = movevars(LGD, 'ID', 'Before', 'S1');
disp(LGD)
ID      S1      S2      S3      S4      S5
____    ____    ____    ____    ____    ____

1304    0.25    0.23    0.21    0.19    0.17
2067    0.24    0.22     0.2    0.18    0.16

Create a table for the portfolio EAD that contains the EAD for the two companies 1304 and 2067.

____    _______

1304      1e+05
1304      90000
1304      80000
1304      70000
1304      60000
1304      50000
1304      40000
2067    1.2e+05
2067    1.1e+05
2067      1e+05
2067      90000

Use portfolioECL with PD, LGD, and EAD Tables

Compute the lifetime ECL using portfolioECL.

[totalECL, ECLByID, ECLByPeriod] = portfolioECL(PD, LGD, EAD,ScenarioProbabilities=[0.1 0.2 0.3 0.2 0.2], ...

Display the total portfolio ECL.

disp(totalECL);
510.5860

Display the scenario weighted ECLs for each individual loan.

disp(ECLByID);
ID      ECL
____    ______

1304    430.68
2067    79.905

Display the ECL for each individual loan per time period and per scenario.

disp(ECLByPeriod);
ID     TimePeriod    Severe    Adverse    Baseline    Favorable    Excellent
____    __________    ______    _______    ________    _________    _________

1304        1         281.84     220.8       171.1      130.95       98.781
1304        2         174.81    142.76      115.47      92.372       72.935
1304        3         96.647    81.317      67.817      55.978        45.64
1304        4         53.474    46.505      40.111      34.259       28.918
1304        5         28.426     25.63      22.924      20.311        17.79
1304        6         14.859    13.715      12.559      11.393       10.217
1304        7         7.9931    7.3777      6.7558      6.1282       5.4957
2067        1         63.693    48.183      36.026      26.576       19.296
2067        2         37.901    30.106      23.673      18.394       14.091
2067        3           19.8    16.293      13.284      10.711       8.5209
2067        4         10.449    8.9412      7.5839      6.3656       5.2748

## Input Arguments

collapse all

Marginal PD values, specified as a table with a column for IDs that is defined by IDVar.

Note

The MarginalPD table column name for IDs and the order of IDs must be the same as the ID columns of the LGD and EAD tables.

You can use fitLifetimePDModel to create a PD model and predict to create a vector that can be converted to a table using array2table.

Data Types: table

LGD value, specified as a table with a column for IDs that is defined by IDVar.

Note

The LGD table column name for lDs and the order of IDs must be the same as the ID columns of the MarginalPD and EAD tables.

You can use fitLGDModel to create a LGD model and predict to create a vector that can be converted to a table using array2table.

Data Types: table

EAD value, specified as a table with a column for IDs that is defined by IDVar.

Note

The EAD table column name for IDs and the order of IDs must be the same as the ID columns of the MarginalPD and LGD tables.

You can use fitEADModel to create a EAD model and predict to create a vector that can be converted to a table using array2table.

Data Types: table

### Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Probabilities assigning weights to corresponding scenarios, specified as ScenarioProbabilities and a numeric vector. The ScenarioProbabilities values must be greater than or equal to 0 and sum to 1.

Data Types: double

Interest rate to discount future losses back to present, specified as InterestRate and a scalar positive or negative decimal or a table.

• If you specify a scalar, the interest-rate value applies to the entire portfolio.

• If you specify a table, there must be exactly two columns in the interest-rate table, one for IDs and the other for the interest-rate value for each loan. Each row must have an ID that cannot be repeated on another row in the table. The IDs must match and be in the same order as the IDs used by MarginalPD, LGD, and EAD tables.

Data Types: double | table

Time period of input data, specified as Periodicity and a character vector or string.

Data Types: char | string

Column name for ID in MarginalPD, LGD, and EAD tables, specified as IDVar and a character vector or string.

Data Types: char | string

User-defined scenario names with one name per scenario, specified as ScenarioNames and a cell array of character vectors or string array. The ScenarioNames must all be unique and nonempty.

Data Types: cell | string

## Output Arguments

collapse all

Total portfolio ECL, returned as a scalar. The total portfolio ECL is computed as a sum of the ECLs of each loan weighted by the scenario probabilities and discounted to the present.

Scenario weighted ECLs for each individual loan, returned as a table.

ECL for each individual loan per time period and per scenario, returned as a table.

collapse all

### Expected Credit Losses

The expected credit losses (ECLs) model adopts a forward-looking approach to estimation of impairment losses.

• The discounted ECL at time t for scenario s is defined as

$EC{L}_{i}\left(t;s\right)=P{D}_{m\mathrm{arg}inal,i}\left(t;s\right)LG{D}_{i}\left(t;s\right)EA{D}_{i}\left(t;s\right)Dis{c}_{i}\left(t\right)$

where

t denotes a time period.

s denotes a scenario.

i denotes a loan.

PDmarginal,i(t;s) is the marginal probability of default (PD) (see predictLifetime) for loan i at time period t, given scenario s.

LGDi(t;s) is the loss given default (LGD) for loan i at time period t, given scenario s.

EADi(t;s) is the exposure at default (EAD) for loan i at time period t, given scenario s.

Disci(t) is the discount factor for loan i at time period t, based on the loan's effective interest rate.

The ECLi(t;s) quantities are computed for each time period in the remaining life of a loan and for each scenario. These quantities are reported in the ECLByPeriod output of portfolioECL for all loans in the portfolio.

• The lifetime ECL for loan i is computed as

$EC{L}_{i}={\sum }_{s=1}^{M}{\sum }_{t=1}^{{N}_{i}}EC{L}_{i}\left(t;s\right)\ast P\left(s\right)$

where

Ni is the number of periods in the remaining life of loan i.

M is the number of scenarios.

P(s) denotes the scenario probabilities.

The ECLi quantity is reported in the ECLByID output of portfolioECL for all loans in the portfolio.

• The total portfolio lifetime ECL is

$ECL={\sum }_{i=1}^{L}EC{L}_{i}$

where

L is the number of loans in the portfolio.

The total ECL value for the portfolio is reported in the totalECL output of the portfolioECL function.

To compute an ECL spanning only 1-year ahead (as opposed to a lifetime ECL), the inputs to portfolioECL must only include time periods within the 1-year period of interest. For more information, see Incorporate Macroeconomic Scenario Projections in Loan Portfolio ECL Calculations.

## Version History

Introduced in R2022a