Skip to content

[FEAT] Hurlimann Credible Loss Ratio estimator - #1552

Closed
genedan wants to merge 5 commits into
mainfrom
hurlimann-verification
Closed

genedan wants to merge 5 commits into
mainfrom
hurlimann-verification

Conversation

@genedan

@genedan genedan commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Summary of Changes

Add a new estimator, HurlimannCLR to implement the Hurlimann paper.

Related GitHub Issue(s)

#1502

AI/LLM Usage

Claude Opus 5.5

Additional Context for Reviewers

Submitter's Checklist

  • I have reviewed and am adhering to the standards outlined in the project Governing Doc.
  • The PR subject title summarizes the changes, with one proper prefix ([FIX], [FEAT], [DOCS], [TST], [CHORE], or [BRK]).
  • I am a human (not a bot), and this PR form is written by a human.

Reviewer's Checklist

  • The implementation addresses the associated issue(s).
  • The implementation is appropriate, maintainable, and follows ARCHITECTURE.md.
  • PR subject title has the proper prefix and the subject is appropriate.
  • Relevant issue(s) are linked.
  • AI/LLM usage is disclosed and appropriate.
  • Documentation and tests are appropriate.
  • CI tests passed, or any failures are acceptable.
  • Leave a comment with the final recommendation (e.g. approve as is, request a secondary review, or flag an area for more review).

Note

Low Risk
Additive reserving method with no changes to existing estimators; risk is mainly actuarial correctness, which is heavily regression-tested against published examples.

Overview
This PR introduces HurlimannCLR, a new IBNR estimator implementing Hürlimann’s credible loss ratio model. Reserves blend individual and collective components via a selectable credibility weight (optimal, benktander, neuhaus, collective, individual), with payout patterns driven by incremental claims and required exposure passed as sample_weight rather than link-ratio development factors.

The implementation bypasses the usual MethodBase development fit, exposes diagnostic triangles (m_, elr_, p_, credibility_, mse_, etc.), and does not support predict. HurlimannCLR is wired into the package exports, API docs, and bibliography.

Coverage includes extensive pytest checks against the paper’s Section 7 tables (with errata) plus a user-guide verification notebook.

Reviewed by Cursor Bugbot for commit 381fd8d. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.46%. Comparing base (b44fedc) to head (381fd8d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1552      +/-   ##
==========================================
+ Coverage   94.39%   94.46%   +0.07%     
==========================================
  Files          98      100       +2     
  Lines        6222     6307      +85     
  Branches      799      803       +4     
==========================================
+ Hits         5873     5958      +85     
  Misses        225      225              
  Partials      124      124              
Flag Coverage Δ
unittests 94.46% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@genedan genedan closed this Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Pyright Type Completeness

View the full pyright --verifytypes output for this commit

Project (full chainladder package, at this PR's head): 16.1% of exported symbols fully typed (264 / 1636)

Known Ambiguous Unknown Total
Project (head) 264 105 1267 1636

Other symbols referenced but not exported by chainladder: 24

Known Ambiguous Unknown Total
Other (head) 11 1 12 24

Symbols without documentation:

  • Functions without docstring: 347
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): 11.1% fully typed (5 / 45)

Known Ambiguous Unknown Total
Patch 5 1 39 45
Patch symbol details
Symbol Status Change
chainladder.HurlimannCLR ❌ unknown new
chainladder.methods.HurlimannCLR ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.X_ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.__init__ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.credibility_ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.elr_ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.fit ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.m_ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.method ⚠️ ambiguous new
chainladder.methods.hurlimann.HurlimannCLR.mse_ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.p_ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.predict ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.r_collective_ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.r_individual_ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.sample_weight_ ❌ unknown new
chainladder.methods.hurlimann.HurlimannCLR.ultimate_ ❌ unknown new
chainladder.methods.tests.test_hurlimann.EXAMPLES ❌ unknown new
chainladder.methods.tests.test_hurlimann.METHODS ✅ known new
chainladder.methods.tests.test_hurlimann.ROWS_7_1 ✅ known new
chainladder.methods.tests.test_hurlimann.ROWS_7_6 ✅ known new
chainladder.methods.tests.test_hurlimann.example ✅ known new
chainladder.methods.tests.test_hurlimann.exposure ❌ unknown new
chainladder.methods.tests.test_hurlimann.fits ✅ known new
chainladder.methods.tests.test_hurlimann.incremental_triangle ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_attributes_are_triangles ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_backends ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_credibility_mixture ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_credibility_weights ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_default_method_is_optimal ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_estimator_api ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_exposure_scale ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_fully_developed_origin ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_incremental_equals_cumulative ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_invalid_method ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_mse_ratio_to_optimal ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_origin_mismatch ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_parameters ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_pattern_independent_of_method ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_predict_not_supported ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_reserves ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_sample_weight_required ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_segments_equal_separate_fits ❌ unknown new
chainladder.methods.tests.test_hurlimann.test_ultimates ❌ unknown new
chainladder.methods.tests.test_hurlimann.values ❌ unknown new

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 381fd8d. Configure here.

inc = inc_tri.values # (index, column, origin, development)
# Exposure of each origin, broadcast to the shape of X.
V = self.sample_weight_.set_backend("numpy").latest_diagonal.values
V = np.broadcast_to(V, inc.shape[:3] + (1,))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weights paired by position not labels

Medium Severity

fit only checks that X and sample_weight have the same number of origin periods, then reads both as numpy arrays. Origins and index rows are paired by position, so matching counts with different or reordered labels still run and assign the wrong exposures to the loss ratio pattern and reserves.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 381fd8d. Configure here.

)
# Skip MethodBase.fit: it fits a Development, which this method does not use.
X = X.incr_to_cum().val_to_dev() if not X.is_cumulative else X.val_to_dev()
self.X_ = X

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pattern properties crash after fit

Low Severity

fit skips MethodBase.fit, so X_ never gets ldf_. Inherited full_triangle_ then fails with a missing ldf_ error on the triangle. predict already raises a clear NotImplementedError; these pattern-based attributes do not.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 381fd8d. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant