Main Content


Create specified LGD model object type

Since R2021a



lgdModel = fitLGDModel(data,ModelType) creates a loss given default (LGD) model object specified by data and ModelType. fitLGDModel takes in credit data in table form and fits a LGD model. ModelType is supported for Regression, Tobit, or Beta.


lgdModel = fitLGDModel(___,Name,Value) specifies options using one or more name-value pair arguments in addition to the input arguments in the previous syntax. The available optional name-value pair arguments depend on the specified ModelType.


collapse all

This example shows how to use fitLGDModel to create a Regression model for loss given default (LGD).

Load LGD Data

Load the LGD data.

load LGDData.mat
      LTV        Age         Type           LGD   
    _______    _______    ___________    _________

    0.89101    0.39716    residential     0.032659
    0.70176     2.0939    residential      0.43564
    0.72078     2.7948    residential    0.0064766
    0.37013      1.237    residential     0.007947
    0.36492     2.5818    residential            0
      0.796     1.5957    residential      0.14572
    0.60203     1.1599    residential     0.025688
    0.92005    0.50253    investment      0.063182

Create Regression LGD Model

Use fitLGDModel to create a Regression model using the data.

lgdModel = fitLGDModel(data,'regression',...
        'Description','Example LGD regression model.',...
        'PredictorVars',{'LTV' 'Age' 'Type'},...
  Regression with properties:

    ResponseTransform: "logit"
    BoundaryTolerance: 1.0000e-05
              ModelID: "Example"
          Description: "Example LGD regression model."
      UnderlyingModel: [1x1 classreg.regr.CompactLinearModel]
        PredictorVars: ["LTV"    "Age"    "Type"]
          ResponseVar: "LGD"
           WeightsVar: ""

Display the underlying model. The underlying model's response variable is the logit transformation of the LGD response data. Use the 'ResponseTransform' and 'BoundaryTolerance' arguments to modify the transformation.

ans = 
Compact linear regression model:
    LGD_logit ~ 1 + LTV + Age + Type

Estimated Coefficients:
                       Estimate       SE        tStat       pValue  
                       ________    ________    _______    __________

    (Intercept)        -5.1939      0.28351     -18.32     1.203e-71
    LTV                 3.3217      0.33058     10.048    1.9484e-23
    Age                -1.4953     0.068658    -21.779    1.0596e-98
    Type_investment     1.3813      0.19406     7.1178    1.3259e-12

Number of observations: 3487, Error degrees of freedom: 3483
Root Mean Squared Error: 4.3
R-squared: 0.195,  Adjusted R-Squared: 0.194
F-statistic vs. constant model: 281, p-value = 2.32e-163

Predict LGD

For LGD prediction, the LGD model applies the inverse transformation so the predictions are in the LGD scale, not in the transformed scale used to fit the underlying model.

predictedLGD = predict(lgdModel,data);
title('Predicted LGD Histogram')
xlabel('Predicted LGD')

Validate LGD Model

For model validation, use modelDiscrimination, modelDiscriminationPlot, modelCalibration, and modelCalibrationPlot.

For example, use modelDiscriminationPlot to plot the ROC curve.


Use modelCalibrationPlot to show a scatter plot of the predictions.


Input Arguments

collapse all

Data for loss given default, specified as a table.

Data Types: table

Type of LGD model, specified as a scalar string or character vector. Use one of following values:

Data Types: string | char

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.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: lgdModel = fitLGDModel(data,'regression','PredictorVars',{'LTV' 'Age','Type'},'ResponseVar','LGD','ResponseTransform','probit','BoundaryTolerance',1e-6)

The available name-value pair arguments depend on the value you specify for ModelType.

Output Arguments

collapse all

Loss given default model, returned as an lgdModel object. Supported classes are Regression, Tobit, and Beta.


[1] Baesens, Bart, Daniel Roesch, and Harald Scheule. Credit Risk Analytics: Measurement Techniques, Applications, and Examples in SAS. Wiley, 2016.

[2] Bellini, Tiziano. IFRS 9 and CECL Credit Risk Modelling and Validation: A Practical Guide with Examples Worked in R and SAS. San Diego, CA: Elsevier, 2019.

Version History

Introduced in R2021a

expand all