← Back to selected work

Supporting project P1 · Credit risk analytics · Public data (Freddie Mac SFLLD, 2014 vintage sample)

Which mortgages default — and by how much?

A full statistical workflow on 50,000 real US mortgages (3.39 million monthly records): audited ingestion, risk-factor analysis, and a logistic model validated out-of-cohort — executed under licence terms that never let a raw row leave its owner.

Completed v1.0 · Aggregates verified twice independently Data: public sample, licence-restricted raw rows R + statistics-first
50,000loans · 2014 vintage sample
3,394,276monthly performance rows
3.87%ever-90+ DPD default rate (1,936 loans)
1.02out-of-cohort calibration slope (ideal 1.00)
≈0.69AUC (cell-level approximation)
47%of defaults captured by riskiest 20% of cells

What is real and what isn't — on this page

Real

  • Every number: computed from the authentic Freddie Mac 2014-vintage sample files (50,000 loans), fetched under free research registration.
  • Every chart: rendered from aggregate tables that passed two independent verification passes (sums, joins, and a from-scratch re-parse of the origination file).
  • The model, its coefficients, confidence intervals and validation metrics: computed by R/02_model.R — output reproduced in full below.
  • The six documented build bugs and data traps (trailing pipes, NA codes, unmatched reference files…), in AI_GOT_IT_WRONG.md.

Not on this page (by design and by licence)

  • No loan-level rows anywhere online — licence prohibits re-posting raw or derived records; the aggregate layer is the only data here.
  • No claim that US mortgage conclusions apply to Nigerian lending — only the method transfers.
  • No production-readiness claim: this is a statistical study of one vintage, not a deployable scorecard.
  • No AI hype: code was AI-assisted, and every failure it caused was caught by checks — documented, count and all.

00 The two-minute version

Headline: on 50,000 real 2014-vintage US mortgages, a logistic model fitted only on earlier originations predicts later ones at almost exactly the right rates — out-of-cohort calibration slope 1.02 (ideal 1.00) on 33,691 unseen loans; FICO is the dominant divider, 17.0% vs 1.5% default across the extreme bands.

Business question
Which origination factors move mortgage default risk — and does a model trained on earlier loans still price later ones correctly?
Data
50,000 real loans (Freddie Mac SFLLD 2014 sample), 3,394,276 monthly records; licence-safe aggregates only, every table verified twice. REAL
Method
Audit-first base-R ingestion → locked default definition (ever 90+ days delinquent) → grouped-binomial logistic model → out-of-cohort (origination-time) validation (train 16,275 loans; test 33,691). REAL
Result
Clean monotone FICO ladder (adjusted odds 6.9× between extreme bands, 95% CI 4.5–10.5); LTV effect appears only ≥90%; undisclosed DTI defaulting at 8.6% — worse than every disclosed band; riskiest 20% of cells capture 47% of unseen defaults. REAL
Recommendation
For a book like this: price sub-700 FICO materially higher, and treat missing DTI as a red-flag feature, not noise. Magnitudes are US-specific — the discipline transfers, the numbers don't.
Limitations
One vintage; banded aggregates (licence constraint); ~19% of loans observed <24 months; cell-level AUC ≈0.69 understates loan-level maximum.
Next steps
Second vintage · survival/competing-risks framing · approval-cutoff and stability extension (now in the repository: R/03_cutoff_stability.R).

01The Problem

If you lend money on homes, three numbers decide whether a loan is safe: the borrower's credit score, how leveraged the property is (loan-to-value), and why the loan exists. This project quantifies that intuition on real data and stress-tests whether a model built on older originations still explains newer ones.

The framing statistic of the study: only 3.872% of these 50,000 prime-era mortgages ever reached 90+ days delinquent in 12+ years of observation — so the interesting questions are discrimination (can we rank risk?), calibration (are rates predicted accurately?), and stability over time — not raw accuracy. "96% of my model's predictions were correct" would mean nothing here; predicting "nobody defaults" scores 96.1%.

Why this dataset, as a Nigerian analyst: the Freddie Mac Single-Family Loan-Level Dataset is the most thoroughly audited public credit dataset available — perfect for proving an end-to-end risk-analytics workflow (ingest → audit → analyse → model → validate → report). The method is what a mortgage or consumer-lending team anywhere would run; the magnitudes are US-specific and I never claim otherwise.

02The Data

One vintage-year random sample: 50,000 loans originated in 2014, each tracked monthly from acquisition to March 2026 or termination (3,394,276 rows). Pipe-delimited text, no header rows — schema comes from the official file layout.

Dataset / documentPublisherURLVerifiedLicenceContentUsed forStatusLimits
SFLLD vintage sample — origination file Freddie Mac freddiemac.com/research/datasets/sf-loanlevel-dataset → Clarity Data Download 2026-10-21 Free research registration; redistribution prohibited 50,000 rows × 31 fields Risk factors (FICO, DTI, LTV, purpose…) REAL — never published Sample ≠ population; one vintage
SFLLD vintage sample — performance file Freddie Mac same as above 2026-10-21 same 3,394,276 rows × 35 fields, periods 201401–202603 Outcome construction (delinquency, termination) REAL — never published Censoring (81.6% prepay early)
File layout, headers, general user guide (July 2026) Freddie Mac freddiemac.com/fmac-resources/research/ (public) 2026-10-21 (downloaded) Public documentation 31 + 35 field schemas; code definitions Schema, data dictionary, automated checks REAL July-2026 layout ≠ older releases
Free Terms & Conditions (SFLLD) Freddie Mac capitalmarkets.freddiemac.com/crt/docs/pdfs/fre_terms_conditions_sflld.pdf 2026-10-21 Terms document 2 pages Defines the aggregates-only architecture REAL —
Release-47 public reference sample Freddie Mac (public) freddiemac.com/fmac-resources/research/docs/release-47-sample-files.zip 2026-10-21 Public 1,000 + 1,011 rows Pipeline smoke test only REAL (format examples — 0 shared loan IDs, verified) Not a matched dataset; never analysed
Verified aggregate layer (16 files) This project data/aggregates/ (repository) 2026-10-21/24 Derived non-recreatable aggregates — publishable per terms Band tables, cell tables, tallies + verification log Modelling input; all charts on this page REAL, twice-reconciled Small cells (n<10) suppressed: 34 loans, 1 default excluded & disclosed
Licence boundary, stated plainly: the free terms allow research use and publishing aggregate results, and prohibit "re-posting, or otherwise making available … the Dataset (in whole or in part) or any Derived Products to any third party." So raw rows stayed with the data owner; code travelled to the data, and only counts and rates came back — every one then re-summed and cross-checked before a single finding was written.

03The Process

How an "I can't upload the file" problem became a better, licence-proof design — the pipeline moves to the data, and every returned number is treated as untrusted until independently re-verified.

  1. Schema first, code second. Field maps were built from the official July-2026 file layout — 31 origination + 35 performance fields — before writing parsers. The import script (01_import_checks.R) measures row width by pipe-count (a trailing | made strsplit under-count in tests), aborts loudly on unknown layouts, and refuses to run on unverified input.
  2. Automated audit battery. Field-width distribution, row/loan counts, duplicate-ID scan, range checks against the data dictionary (FICO 300–850; DTI ≤65; LTV 6–105 for this era), missingness per key field, and the one that mattered most early: the loan-ID join check (Freddie's public "reference sample" turned out to contain zero shared IDs between its two files — format examples, not mini-data; the real vintage sample joined 50,000/50,000).
  3. Missing-value codes cleaned before analysis. 999/9999 disclosures recoded to NA with explicit "Not Available" categories kept — because EDA later proved undisclosed-DTI loans default at 8.6% vs 4.0% max visible band. Deleting them would have deleted signal.
  4. Locked outcome definition before modelling. Default ≡ ever delinquency status ≥ 03 (90+ days) — a definition that subsumes REO acquisitions (82 loans) and adverse terminations (171 loans: short-sale/charge-off/third-party/REO disposition), verified by set arithmetic.
  5. Aggregates-only relay + independent verification. Aggregate tables were computed data-owner-side; on return, every table was re-summed (all equal 50,000 / 1,936), join counts re-checked, and band counts reconciled against a from-scratch re-parse of the origination file before being accepted into data/aggregates/.
  6. AI-assisted, QA-first. Code was built with AI assistance and six real bugs/traps were caught and logged before any output shipped — published as AI_GOT_IT_WRONG.md in the repository because the debugging record is part of the competence on display.

04What the data showed

Each chart below comes with the "so what" it forced into the modelling decision.

Bar chart: ever-default rate by FICO band, falling from 17.0% for under-620 to 1.5% for 780+, against a 3.87% vintage baseline
FICO is the single dominant risk axis — perfectly monotone.So whatEntered the model as the headline factor — but as bands, because only banded aggregates are publishable under the licence; the cost of that choice is disclosed in §07.
Bar chart: default rate by DTI band rising 1.3% to 4.7%, with the not-available group at 8.6%
DTI rises cleanly — and "Not Available" is its own risk signal.So whatMissingness was kept as an explicit category, never silently dropped: 14.6% of loans carry the 999 code and default at nearly double the highest visible band.
Bar chart: default rate by LTV band, flat near 3.3-3.5% up to 89, rising at 90+, and 14.1% for the 106+ group
LTV is flat until ~90%, then breaks.So whatThe 934 loans above 105% (relief-refinance-era disclosures) default at 14.1% — a data-quality flag became a model cell of its own instead of a silent recode.
Three small bar panels: default rate by loan purpose, occupancy and origination channel
Purpose, occupancy, channel — second-order but real gradients.So whatNo-cash-out refis defaulting above purchases (5.4% vs 2.9%) is counterintuitive and was checked rather than smoothed over: post-crisis refis self-selected borrowers already uneasy. Purpose entered the model; occupancy/channel noted as descriptive.
Horizontal stacked bar partitioning 50,000 loans into prepaid 40,813, still active 8,739, whole-loan sales 182, adverse terminations 171, defects 95
The honest headline: 81.6% of loans prepaid before default was even possible.So what"Ever-default" is a right-censored, competing-risks outcome here; the model predicts it as such and the limits section states what a production version would need (survival/competing-risk framing).
Bar chart: default rate by origination quarter, stable between 3.70% and 4.07%
Base rates are stable across originations (3.70–4.07%).So whatStability makes the origination-quarter train/test split a meaningful out-of-cohort test rather than a foregone failure.

05The Model

A grouped-binomial logistic regression — the classical GLM where each row is a band-combination cell with defaults vs non-defaults. It is exactly what the licence allows to travel, and R fits it natively with proper weights, standard errors and confidence intervals.

Formula: cbind(defaults, n − defaults) ~ fico_band + ltv_band + purpose · fitted on the H1 cells only (loans first-paid Jan–Jun 2014: 16,275 loans, 642 defaults) · references = safest cells (FICO ≥780, LTV <60, purchase) · overdispersion φ = 1.28 → native binomial SEs retained (quasi-binomial fallback pre-wired).
Forest plot of odds ratios with 95% confidence intervals: FICO bands 6.88 down to 1.65, LTV 90-94 1.48, 95-105 1.94, 106+ 2.65, purpose cash-out 1.39 and no-cash-out 1.87
Odds ratios vs the safest cell, with 95% CIs. Every FICO step down multiplies default odds; LTV only clears significance above ~90%; refinance purpose adds measurable risk after adjusting for both.
TermOdds ratio95% CIp-valueReading
FICO <620 (vs ≥780)6.884.49 – 10.55<0.001≈7× the default odds of the cleanest-score cell
FICO 620–6595.834.18 – 8.12<0.001gradient holds band by band
FICO 660–6994.453.36 – 5.90<0.001—
FICO 700–7393.042.30 – 4.00<0.001—
FICO 740–7791.651.23 – 2.20<0.001still measurably riskier than ≥780
LTV 60–89 (vs <60)1.03 – 1.25cross 1.0not significantstated honestly — flat region
LTV 90–941.481.03 – 2.130.033risk surface lifts at ~90%
LTV 95–1051.941.43 – 2.64<0.001—
LTV 106+2.651.87 – 3.76<0.001the flagged outlier cells are really riskier — after adjusting for FICO & purpose
Purpose: cash-out refi (vs purchase)1.391.05 – 1.830.022—
Purpose: no-cash-out refi1.871.52 – 2.29<0.001the counterintuitive EDA finding survives adjustment

Baseline (intercept): a FICO≥780 · LTV<60 · purchase loan carries a fitted lifetime-default probability of ≈0.9%. Full machine-readable coefficient set: model_outputs/coefficients_or.csv.

06Does it hold out-of-cohort?

Train quarters (Jan–Jun 2014) were never seen by the test: the model was scored on H2 — 33,691 loans originated later (Jul 2014 → 2015 spillover).

Calibration chart: observed default rate per predicted-risk decile tracks the model prediction closely, from 0.9% to 10.4%
Observed tracks predicted decile by decile.So whatCalibration slope 1.016 and intercept 0.086 (≈9% conservative underprediction): the model means what it says on loans it never saw.
Metric (H2 holdout)ValueHonest label
Test base rate3.838% (1,293 / 33,691)exact — computed
Calibration intercept (in-the-large)0.086exact (offset GLM) · 0 = perfect
Calibration slope1.016exact (offset GLM) · 1 = perfect
AUC / Gini≈0.69 / ≈0.39cell-level approximation — within-cell risk assumed homogeneous; a loan-level score would sit a little higher
Brier (cell-weighted) vs base-rate null0.00024 vs 0.00121 → skill 0.80cell-level: loan-level Brier is higher by the within-cell variance — not comparable to loan-level benchmarks
Top-20% predicted-risk cellscapture 47.1% of all test defaultsexact — computed
Excluded cells34 loans, 1 defaultsuppressed (n<10) upstream — disclosed, never hidden

07Limits — said before you ask

  1. Right-censoring & competing risks. 81.6% of loans prepaid early; "ever-default by Mar-2026" is a lifetime outcome. A production build needs a survival/competing-risk model — named here because this page doesn't pretend otherwise.
  2. Banded resolution. The licence caps us at aggregates, so FICO entered as 6 bands, not a continuous score — discrimination is understated by design; the tradeoff was legal necessity and is priced into the wording.
  3. One vintage, one split. H1→H2 is a true origination-time test but a single macro regime. A second vintage (e.g. 2016/2017) re-uses this exact pipeline unchanged; queued, not faked.
  4. Scope discipline: US agency mortgages generalize as method, never as effect sizes, to Nigeria or anywhere else. Nothing here is a lending recommendation.
  5. AI assistance disclosed: code was AI-assisted; all six build-breaking bugs it introduced are logged with fixes in AI_GOT_IT_WRONG.md. Verification, definitions, and interpretations are mine.

08Why this matters to a hiring team

  1. Comfortable with real-world ugliness: no-header pipes, NA codes, drifting layouts, unmatched reference files — handled with checks, never vibes.
  2. Governance literacy that is rare at entry level: the licence shaped the architecture itself. If your organisation's data can't leave the building, this page is the proof-of-pattern.
  3. Statistical judgement over tool flash: imbalance recognised → calibration-first evaluation → honest approximations with labels, rather than a borrowed "94% accuracy".
  4. End-to-end finish: ingest checks, EDA with "so what"s, model with CIs, out-of-cohort (origination-time) validation, model card, exec brief, chart pack, and a debugging paper trail.

Next for this project: second vintage for cross-regime validation · survival/competing-risk extension · DTI-inclusive model (needs one more aggregate split for a fair time test). All labelled when they land.

09Tools used

  • R (base, zero-dependency): chunked pipe importer, audit battery, rollup, grouped-binomial GLM, calibration machinery — R/01_import_checks.R, R/02_model.R (seeded, commented for explanation).
  • Python: report parsing into the verified aggregate CSVs; matplotlib chart rendering.
  • Statistics: grouped logistic regression, overdispersion testing, offset-GLM calibration intercept/slope, Mann–Whitney cell-approximation AUC.
  • Practice: small-cell suppression (n<10), reproducible-file discipline, licence-aware data handling, AI-assistance disclosure with a bug ledger.

Named paths (R/…, AI_GOT_IT_WRONG.md, SOLUTIONS_LOG.md) are relative to this project's repo folder — browse the files on GitHub ↗ (verified live 2026-10-25).