predict
Description
computes the loss given default (LGD). LGD = predict(lgdModel,data)
When using a Regression model, the
predict function operates on the underlying compact
statistical model and then transforms the predicted values back to the LGD
scale.
When using a Tobit model, the
predict function operates on the underlying
Tobit regression model and returns the unconditional expected
value of the response, given the predictor values.
Examples
This example shows how to use fitLGDModel to fit data with a Regression model and then predict the loss given default (LGD) values.
Load Data
Load the loss given default data.
load LGDData.mat
head(data) 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
Partition Data
Separate the data into training and test partitions.
rng('default'); % for reproducibility NumObs = height(data); c = cvpartition(NumObs,'HoldOut',0.4); TrainingInd = training(c); TestInd = test(c);
Create Regression LGD Model
Use fitLGDModel to create a Regression model using training data.
lgdModel = fitLGDModel(data(TrainingInd,:),'regression');
disp(lgdModel) Regression with properties:
ResponseTransform: "logit"
BoundaryTolerance: 1.0000e-05
ModelID: "Regression"
Description: ""
UnderlyingModel: [1×1 classreg.regr.CompactLinearModel]
PredictorVars: ["LTV" "Age" "Type"]
ResponseVar: "LGD"
WeightsVar: ""
Display the underlying model.
disp(lgdModel.UnderlyingModel)
Compact linear regression model:
LGD_logit ~ 1 + LTV + Age + Type
Estimated Coefficients:
Estimate SE tStat pValue
________ ________ _______ __________
(Intercept) -4.7549 0.36041 -13.193 3.0997e-38
LTV 2.8565 0.41777 6.8377 1.0531e-11
Age -1.5397 0.085716 -17.963 3.3172e-67
Type_investment 1.4358 0.2475 5.8012 7.587e-09
Number of observations: 2093, Error degrees of freedom: 2089
Root Mean Squared Error: 4.24
R-squared: 0.206, Adjusted R-Squared: 0.205
F-statistic vs. constant model: 181, p-value = 2.42e-104
Predict LGD on Test Data
Use predict to predict the LGD for the test data set.
predictedLGD = predict(lgdModel,data(TestInd,:))
predictedLGD = 1394×1
0.0009
0.0037
0.1877
0.0011
0.0112
0.0420
0.0529
0.0000
0.0090
0.0239
0.0035
0.0065
0.0720
0.0061
0.0012
⋮
You can analyze and validate these predictions using modelDiscrimination and modelCalibration.
This example shows how to use fitLGDModel to fit data with a Tobit model and then predict the loss given default (LGD) values.
Load Data
Load the loss given default data.
load LGDData.mat
head(data) 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
Partition Data
Separate the data into training and test partitions.
rng('default'); % for reproducibility NumObs = height(data); c = cvpartition(NumObs,'HoldOut',0.4); TrainingInd = training(c); TestInd = test(c);
Create Tobit LGD Model
Use fitLGDModel to create a Tobit model using training data.
lgdModel = fitLGDModel(data(TrainingInd,:),'tobit');
disp(lgdModel) Tobit with properties:
CensoringSide: "both"
LeftLimit: 0
RightLimit: 1
Weights: [0×1 double]
ModelID: "Tobit"
Description: ""
UnderlyingModel: [1×1 risk.internal.credit.TobitModel]
PredictorVars: ["LTV" "Age" "Type"]
ResponseVar: "LGD"
WeightsVar: ""
Display the underlying model.
disp(lgdModel.UnderlyingModel)
Tobit regression model:
LGD = max(0,min(Y*,1))
Y* ~ 1 + LTV + Age + Type
Estimated coefficients:
Estimate SE tStat pValue
_________ _________ _______ __________
(Intercept) 0.058257 0.027279 2.1356 0.03283
LTV 0.20126 0.03136 6.4177 1.7064e-10
Age -0.095407 0.0072633 -13.135 0
Type_investment 0.10208 0.018077 5.6471 1.8542e-08
(Sigma) 0.29288 0.0057084 51.306 0
Number of observations: 2093
Number of left-censored observations: 547
Number of uncensored observations: 1521
Number of right-censored observations: 25
Log-likelihood: -698.383
Predict LGD on Test Data
Use predict to predict the LGD for the test data set.
predictedLGD = predict(lgdModel,data(TestInd,:))
predictedLGD = 1394×1
0.0879
0.1243
0.3204
0.0934
0.1672
0.2238
0.2370
0.0102
0.1592
0.1989
0.1276
0.1457
0.2618
0.1448
0.0941
⋮
You can analyze and validate these predictions using modelDiscrimination and modelCalibration.
This example shows how to use fitLGDModel to fit data with a Beta model and then predict the loss given default (LGD) values.
Load Data
Load the loss given default data.
load LGDData.mat
head(data) 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
Partition Data
Separate the data into training and test partitions.
rng('default'); % for reproducibility NumObs = height(data); c = cvpartition(NumObs,'HoldOut',0.4); TrainingInd = training(c); TestInd = test(c);
Create Beta LGD Model
Use fitLGDModel to create a Beta model using training data.
lgdModel = fitLGDModel(data(TrainingInd,:),'Beta');
disp(lgdModel) Beta with properties:
BoundaryTolerance: 1.0000e-05
ModelID: "Beta"
Description: ""
UnderlyingModel: [1×1 risk.internal.credit.BetaModel]
PredictorVars: ["LTV" "Age" "Type"]
ResponseVar: "LGD"
WeightsVar: ""
Display the underlying model.
disp(lgdModel.UnderlyingModel)
Beta regression model:
logit(LGD) ~ 1_mu + LTV_mu + Age_mu + Type_mu
log(LGD) ~ 1_phi + LTV_phi + Age_phi + Type_phi
Estimated coefficients:
Estimate SE tStat pValue
________ ________ _______ __________
(Intercept)_mu -1.3772 0.13201 -10.433 0
LTV_mu 0.60269 0.15087 3.9947 6.7021e-05
Age_mu -0.47464 0.040264 -11.788 0
Type_investment_mu 0.45372 0.085143 5.3289 1.0941e-07
(Intercept)_phi -0.16336 0.12591 -1.2974 0.19465
LTV_phi 0.055881 0.14719 0.37965 0.70424
Age_phi 0.22887 0.040335 5.6742 1.5867e-08
Type_investment_phi -0.14102 0.078155 -1.8044 0.071312
Number of observations: 2093
Log-likelihood: -5291.04
Predict LGD on Test Data
Use predict to predict the LGD for the test data set.
predictedLGD = predict(lgdModel,data(TestInd,:))
predictedLGD = 1394×1
0.0937
0.1492
0.3526
0.0964
0.1886
0.2595
0.2677
0.0213
0.1774
0.2256
0.1337
0.1677
0.2916
0.1617
0.1051
⋮
You can analyze and validate these predictions using modelDiscrimination and modelCalibration.
Input Arguments
Loss given default model, specified as a previously created Regression,
Tobit, or Beta object using
fitLGDModel.
Data Types: object
Data, specified as a
NumRows-by-NumCols table with
predictor and response values. The variable names and data types must be
consistent with the underlying model.
Data Types: table
Output Arguments
Loss given default values, returned as a
NumRows-by-1 numeric vector.
More About
Use a Regression, Tobit, or Beta model to predict LGD.
Regression LGD models
first predict on the transformed space using the underlying linear regression model,
and then apply the inverse transformation to return predictions on the LGD scale.
For more information on the supported transformations and their inverses, see Loss Given Default Regression Models.
Tobit LGD models return the
unconditional expected value of the response, given the predictor values. For more
information, see Loss Given Default Tobit Models.
Beta LGD models return the
mean of the beta distribution, given the predictor values. For more information, see
Beta Regression Models.
References
[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 R2021aThe lgdModel input supports an option for a
Beta model object that you can create using fitLGDModel.
See Also
Tobit | Regression | Beta | modelCalibration | modelCalibrationPlot | modelDiscriminationPlot | modelDiscrimination | fitLGDModel
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)