Repository navigation
[DOCS] Show a calendar-period effect with BarnettZehnwirth in the user guide - #1622
Conversation
Adds a "Calendar-period effects" subsection at the end of the BarnettZehnwirth section of docs/user_guide/development.ipynb. A synthetic triangle has every 2017 payment raised by 50%. The cells compare Chainladder, Development(drop_valuation=["2016", "2017"]) and BarnettZehnwirth with an I(valuation == 6) term against the known unpaid amounts, then show a shared indicator for an event scheduled in a future calendar period, with a note on its multiplicative scaling. Developed with an AI assistant (Árbol, running Muse).
Pyright Type CompletenessView the full Project (full
Other symbols referenced but not exported by
Symbols without documentation:
Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1622 +/- ##
=======================================
Coverage 94.94% 94.94%
=======================================
Files 99 99
Lines 6427 6427
Branches 811 811
=======================================
Hits 6102 6102
Misses 207 207
Partials 118 118
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
i'm a big fan of demonstrating how to use this package to solve real world problems, particularly comparing between different approaches. some suggestions to make this even more instructive
|
…on test Run Triangle.valuation_correlation on the synthetic triangle before any model is fitted, in both its total and per-diagonal forms, so the example leads with a test instead of a visual check. Developed with an AI assistant (Árbol, running Muse).
The heatmap ranks each payment within its development age, so the 2017 payments appear as one diagonal. Developed with an AI assistant (Árbol, running Muse).
Friedland's Chapter 7, Exhibit III scenarios with increasing case outstanding strength give a published case of a calendar-period effect in reported claims. The synthetic triangle stays for the remedies, since only it has known unpaid amounts. Developed with an AI assistant (Árbol, running Muse).
|
Thanks, Henry. I pushed three commits that follow your suggestions:
The IBNR numbers are unchanged, and the notebook passes (This comment was written with Árbol, an AI assistant, under my direction.) |
|
thanks for the changes. a couple more comments
|
… it in full Build the square from one long DataFrame with Triangle, add the 2017 shock with a valuation filter, and split it into the 2020 triangle and the true unpaid amounts with valuation filters, in place of the pandas groupby and .loc edits. Give every origin the same expected payments: with a 5% level trend, ratios equal in exact arithmetic differed by about 1e-10, and valuation_correlation split those ties. Show the full square with the cells paid after 2020 shaded and in italics, and explain diagonal by diagonal why the test flags 2017 and 2020 but not 2018 or 2019. Developed with an AI assistant (Árbol, running Muse).
Color the link ratios instead of the incremental payments, rounded to the four decimals heatmap prints so that ratios which print alike share a color. low and high keep every color pale enough for the dark text to stay readable. Developed with an AI assistant (Árbol, running Muse).
…ts section Run valuation_correlation on the friedland_uspp scenarios in the triangle guide, next to the raa example, and keep the calendar-period example in the development guide on the synthetic triangle. Developed with an AI assistant (Árbol, running Muse).
|
Thanks. All five are in 4d7cd8d, 273d052 and 36dee86.
The old "seven of nine" for 2020 was also wrong. The 5% origin trend made ratios that are equal in exact arithmetic differ by about 1e-10, and the test split those ties. Every origin now has the same expected payments, so the ties are exact and the counts in the text match the test. The no-effect range moves to 6.03 to 11.47, and the (This comment was written with Árbol, an AI assistant, under my direction.) |
Summary of Changes
Adds a short "Calendar-period effects" subsection at the end of the BarnettZehnwirth part of
docs/user_guide/development.ipynb. It uses a synthetic triangle (origins 2011 to 2020, the same expected payment at each development age for every origin) in which every payment made in calendar year 2017 is 50% higher. The triangle is built square through 2029 withTriangleoperations, and the example shows it in full with the cells paid after 2020 shaded, so the true unpaid amounts are known. It shows that:Triangle.valuation_correlation(Mack 1994, Appendix H) flags the effect before any model is fitted: the totalzof 3 is below the no-effect range of 6.03 to 11.47, and the per-diagonal test flags 2017 and 2020. The text explains why 2018 and 2019 are not flagged, and a heatmap of the link ratios shows the 2017 diagonal.Chainladderoverstates every origin's IBNR, by up to 23.8% (origin 2017).Development(drop_valuation=["2016", "2017"])removes the ratios into and out of the 2017 diagonal but still misses by -6.4% to +12.8%, because the extra 2017 payments stay in the later cumulative amounts.BarnettZehnwirth(formula="C(origin) + C(development) + I(valuation == 6)")recovers the unpaid amounts (errors round to 0.0), with exp(coefficient) = 1.5. This is the calendar (iota) direction of the PTF framework (Barnett and Zehnwirth 2000), already cited in this section.I((valuation == 6) | (valuation == 11))projects it; the one-off indicator then understates origins 2013 to 2020 by 9.7% to 15.8%.A note says the shared indicator scales the future diagonal multiplicatively, so it fits an event that scales payments in proportion, not one that adds a fixed amount per claim or policy.
In
docs/user_guide/triangle.ipynb, the Correlation Tests section now runs the same test on Friedland's Chapter 7, Exhibit III (friedland_uspp): it flags reported claims, and not paid claims, in the two increasing case outstanding strength scenarios.No code changes. The example does not use
TweedieGLM(see #1619).Related GitHub Issue(s)
None open. #623 (closed) discussed valuation terms in
BarnettZehnwirthformulas.AI/LLM Usage
I drafted this example with Árbol, an AI assistant (running Muse). It wrote the cells, ran them and the notebook tests on main 46727b1, comparing each origin's IBNR with the known unpaid amount of the synthetic triangle. I reviewed the text and the numbers before opening the PR.
Additional Context for Reviewers
The valuation codes (2017 is 6, 2022 is 11) come from
BarnettZehnwirth().model_.valuation_encoder_, which counts years from the earliest valuation (learning.pydivides the valuation rank by the number of development periods per year). The cells were checked to merge cleanly with #1621, which adds a section earlier in the same notebook, and with #1620, which also editstriangle.ipynb.Submitter's Checklist
[FIX],[FEAT],[DOCS],[TST],[CHORE], or[BRK]).Reviewer's Checklist