All Articles
Credit Risk
Intermediate
5 min readJuly 2, 2025

LGD Estimates: Computation & Implementation Using Python

18
#LGD#Loss Given Default#Credit Risk#Python#Data Science#IFRS 9#Basel III#Machine Learning#Financial Modeling#Banking#Quantitative Finance#Actuarial Science#Risk Analytics#scikit-learn#Risk Management

As I have already explained about LGD and the methodology to compute the estimates, this article focuses on the implementation part using Python.


Step 1: Gather Data

Collect the following from historical default events:

  • Exposure at Default (EAD)
  • Recovery cashflows and recovery dates
  • Discount rate (e.g., contractual rate)
import pandas as pd
df = pd.read_csv("defaults_and_recoveries.csv")

Step 2: Discount Recoveries

Use the discount rate r to bring each recovery cashflow back to the default date:

df['pv_recovery'] = df['recovery_amount'] / (1 + df['discount_rate']) ** df['years_since_default']

Step 3: Compute Realized LGDs

Aggregate recoveries per default event and compute LGD:

grouped = df.groupby('default_id').agg({'pv_recovery': 'sum', 'EAD': 'first'})
grouped['LGD'] = 1 - (grouped['pv_recovery'] / grouped['EAD'])

Step 4: Model LGD

Build a regression or tree-based model to link LGD to drivers:

  • Collateral type
  • Macroeconomic indicators
  • Loan seniority
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(X_train, y_train)  # X_train: predictors; y_train: LGD

Step 5: Validate

Backtest using MAE, RMSE, or compare predicted vs. observed LGDs:

from sklearn.metrics import mean_absolute_error
mae = mean_absolute_error(y_test, model.predict(X_test))

How to Interpret Results

  • LGD near 0 → high recovery / strong collateral
  • LGD near 100% → little or no recovery
  • Outliers → investigate data issues, collateral valuation errors, or process inefficiencies

Consequences of Getting LGD Wrong

  • Underestimation → insufficient economic capital, regulatory breach, surprise losses
  • Overestimation → excessive capital buffers, suboptimal pricing, lost competitiveness
  • Poor segmentation → hides risk differences between secured vs. unsecured or product types
  • Ignoring macro linkages → blinds models to cyclical risk

Conclusion

A robust LGD estimation isn't just a statistical exercise — it's central to credit strategy, regulatory compliance, and sustainable profitability. By combining Python's computational power with thoughtful model design and business understanding, risk teams can build models that are transparent, interpretable, and operationally useful.