From 7662ce4e5a3863c378ce305670a181dadda7e0a0 Mon Sep 17 00:00:00 2001 From: "Kenneth S. Hsu" Date: Tue, 7 Nov 2023 07:31:21 -0800 Subject: [PATCH] Roundtable (#470) * Fixed solution link at the top * Fixed URL * Links not working * File paths * Working links * Merged from main * New star history chart * Updated star history graph * Fixed URL * Links not working * File paths * Working links * Merged from main * Some typos * Typos * Typos * Removed duplicated words * Fixed solution link at the top * Fixed URL * Links not working * File paths * Working links * Merged from main * Fixed URL * Links not working * File paths * Working links * Merged from main * Some typos * Typos * Typos * Removed duplicated words * Some typos on the graphs --- .../sandbox_workbook_blank.ipynb | 4 +- .../sandbox_workbook_filled.ipynb | 3935 +++-------------- 2 files changed, 709 insertions(+), 3230 deletions(-) diff --git a/docs/getting_started/online_sandbox/sandbox_workbook_blank.ipynb b/docs/getting_started/online_sandbox/sandbox_workbook_blank.ipynb index 3e824e06..f95a6f46 100644 --- a/docs/getting_started/online_sandbox/sandbox_workbook_blank.ipynb +++ b/docs/getting_started/online_sandbox/sandbox_workbook_blank.ipynb @@ -746,14 +746,14 @@ "plt.bar(\n", " mcl_mod.summary_.to_frame(origin_as_datetime=True).index.year,\n", " mcl_mod.summary_.to_frame(origin_as_datetime=True)[__fill_in_code__],\n", - " label=\"Paid\",\n", + " label=\"Reported\",\n", ")\n", "plt.bar(\n", " mcl_mod.summary_.to_frame(origin_as_datetime=True).index.year,\n", " mcl_mod.summary_.to_frame(origin_as_datetime=True)[__fill_in_code__],\n", " bottom=mcl_mod.summary_.to_frame(origin_as_datetime=True)[__fill_in_code__],\n", " yerr=mcl_mod.summary_.to_frame(origin_as_datetime=True)[__fill_in_code__],\n", - " label=\"Reserves\",\n", + " label=\"IBNR\",\n", ")\n", "plt.legend(loc=\"upper left\")" ] diff --git a/docs/getting_started/online_sandbox/sandbox_workbook_filled.ipynb b/docs/getting_started/online_sandbox/sandbox_workbook_filled.ipynb index 32808ab3..13f7f16f 100644 --- a/docs/getting_started/online_sandbox/sandbox_workbook_filled.ipynb +++ b/docs/getting_started/online_sandbox/sandbox_workbook_filled.ipynb @@ -23,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "be51a379-5efe-420e-b689-3bf93b96ebc8", "metadata": {}, "outputs": [ @@ -53,9 +53,13 @@ "Requirement already satisfied: packaging>=20.0 in /Users/kennethhsu/opt/anaconda3/lib/python3.9/site-packages (from matplotlib->chainladder) (23.1)\n", "Requirement already satisfied: pillow>=6.2.0 in /Users/kennethhsu/opt/anaconda3/lib/python3.9/site-packages (from matplotlib->chainladder) (9.3.0)\n", "Requirement already satisfied: pyparsing>=2.2.1 in /Users/kennethhsu/opt/anaconda3/lib/python3.9/site-packages (from matplotlib->chainladder) (3.0.9)\n", +<<<<<<< HEAD + "Requirement already satisfied: six in /Users/kennethhsu/opt/anaconda3/lib/python3.9/site-packages (from patsy->chainladder) (1.16.0)\n" +======= "Requirement already satisfied: six in /Users/kennethhsu/opt/anaconda3/lib/python3.9/site-packages (from patsy->chainladder) (1.16.0)\n", "\u001b[33mDEPRECATION: nb-black 1.0.7 has a non-standard dependency specifier black>='19.3'; python_version >= \"3.6\". pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of nb-black or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", "\u001b[0mNote: you may need to restart the kernel to use updated packages.\n" +>>>>>>> c23481473ff4beacbcca9e4b5243e2f78b4b5b08 ] } ], @@ -73,7 +77,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "882cc191-5849-471e-8e13-65fdf3e01419", "metadata": {}, "outputs": [], @@ -91,9 +95,12 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "03fdf8fd-ecd1-4df4-b9cf-a4bf01d978f0", "metadata": {}, +<<<<<<< HEAD + "outputs": [], +======= "outputs": [ { "name": "stdout", @@ -105,6 +112,7 @@ ] } ], +>>>>>>> c23481473ff4beacbcca9e4b5243e2f78b4b5b08 "source": [ "import numpy as np\n", "import pandas as pd\n", @@ -134,111 +142,12 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "aa2c95b8-86b4-4846-b950-12c402477ec1", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
AccidentYearDevelopmentYearIncurredPaidReportedClosedPremium
020022002128112318134220361183
12003200396511743137318169175
220042004169952221193223599322
3200520052867430432067295138151
4200620062706635311473307107578
\n", - "
" - ], - "text/plain": [ - " AccidentYear DevelopmentYear Incurred Paid Reported Closed Premium\n", - "0 2002 2002 12811 2318 1342 203 61183\n", - "1 2003 2003 9651 1743 1373 181 69175\n", - "2 2004 2004 16995 2221 1932 235 99322\n", - "3 2005 2005 28674 3043 2067 295 138151\n", - "4 2006 2006 27066 3531 1473 307 107578" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "xyz_df = pd.read_csv(\n", " \"https://raw.githubusercontent.com/casact/chainladder-python/master/chainladder/utils/data/xyz.csv\"\n", @@ -256,21 +165,10 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "4c11052c-291e-439f-ac0f-6736bb2b0b68", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([2002, 2003, 2004, 2005, 2006, 2007, 2008, 1998, 1999, 2000, 2001])" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "xyz_df[\"AccidentYear\"].unique()" ] @@ -285,21 +183,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "cfeca5a6-366f-4abb-b3e9-51c91e7b9336", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "11" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "xyz_df[\"AccidentYear\"].nunique()" ] @@ -322,58 +209,10 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "2b51e0b6-c1d3-4976-8866-4800b15d27ec", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
Triangle Summary
Valuation:2008-12
Grain:OYDY
Shape:(1, 5, 11, 11)
Index:[Total]
Columns:[Incurred, Paid, Reported, Closed, Premium]
" - ], - "text/plain": [ - " Triangle Summary\n", - "Valuation: 2008-12\n", - "Grain: OYDY\n", - "Shape: (1, 5, 11, 11)\n", - "Index: [Total]\n", - "Columns: [Incurred, Paid, Reported, Closed, Premium]" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "xyz_tri = cl.Triangle(\n", " data=xyz_df,\n", @@ -395,9 +234,102 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "fe9309fe-2744-4e4d-beff-0a36c1182386", "metadata": {}, + "outputs": [], + "source": [ + "xyz_tri[\"Incurred\"]" + ] + }, + { + "cell_type": "markdown", + "id": "ed9811e6-5761-4258-9942-19a620540361", + "metadata": {}, + "source": [ + "How about paid?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "278856cf-6d84-4fa6-ac57-4f57755580b8", + "metadata": {}, + "outputs": [], + "source": [ + "xyz_tri[\"Paid\"]" + ] + }, + { + "cell_type": "markdown", + "id": "04114ff8-107a-4c56-ab9a-8c36f53553df", + "metadata": {}, + "source": [ + "# Pandas-like Operations" + ] + }, + { + "cell_type": "markdown", + "id": "433b8ae8-1968-4dfc-a176-c8a8c93c5f97", + "metadata": {}, + "source": [ + "Let's see how `.iloc[...]` and `.loc[...]` similarly to pandas. They take 4 parameters: [index, column, origin, valuation]." + ] + }, + { + "cell_type": "markdown", + "id": "f0452527-796d-4185-929a-97241329b377", + "metadata": {}, + "source": [ + "What if we want the row from AY 1998 Incurred data?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a13a157b-3fe9-4254-bc72-11d4e1705f29", + "metadata": {}, + "outputs": [], + "source": [ + "xyz_tri.iloc[:, 0, 0, :]" + ] + }, + { + "cell_type": "markdown", + "id": "08b8557c-66fe-4a25-a8bf-5413ca1c1fbb", + "metadata": {}, + "source": [ + "What if you only want the valuation at age 60 of AY 1998?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fb20eda1-4e4a-431d-8c8a-21cc87b8c472", + "metadata": {}, + "outputs": [], + "source": [ + "xyz_tri.iloc[:, 0, 0, 4]" + ] + }, + { + "cell_type": "markdown", + "id": "56683ffb-01ef-4e18-ba27-1b8ab31b9ae7", + "metadata": {}, + "source": [ + "Let's use `.loc[...]` to get the incurred triangle." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b8116ded-c788-483c-b2af-fde45b72ee4a", + "metadata": { + "tags": [] + }, +<<<<<<< HEAD + "outputs": [], +======= "outputs": [ { "data": { @@ -592,128 +524,280 @@ "2008 18632.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN" ] }, - "execution_count": 8, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], +>>>>>>> c23481473ff4beacbcca9e4b5243e2f78b4b5b08 "source": [ - "xyz_tri[\"Incurred\"]" + "xyz_tri.loc[:, \"Incurred\", :, :]" ] }, { "cell_type": "markdown", - "id": "ed9811e6-5761-4258-9942-19a620540361", + "id": "c9d515b7-c9a3-4045-ad79-78af1574be8a", "metadata": {}, "source": [ - "How about paid?" + "How do we get the latest Incurred diagonal only?" ] }, { "cell_type": "code", - "execution_count": 9, - "id": "278856cf-6d84-4fa6-ac57-4f57755580b8", + "execution_count": null, + "id": "5bce08b8-bf34-418e-ac3b-db253db44898", + "metadata": {}, + "outputs": [], + "source": [ + "xyz_tri[\"Incurred\"].latest_diagonal" + ] + }, + { + "cell_type": "markdown", + "id": "31b56210-cbcd-4bbb-af9f-063a3788867a", "metadata": {}, + "source": [ + "Very often, we want incremental triangles instead. Let's convert the Incurred triangle to the incremental form." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b2766e7b-b1e6-4574-bfa7-fd70ccd556d7", + "metadata": {}, + "outputs": [], + "source": [ + "xyz_tri[\"Incurred\"].cum_to_incr()" + ] + }, + { + "cell_type": "markdown", + "id": "6235668f-9025-4108-b987-f867f93c8ce6", + "metadata": {}, + "source": [ + "We can also convert the triangle to the valuation format, what we often see on Schedule Ps." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "72487c9a-4438-4ab7-8a24-245485d4c637", + "metadata": {}, + "outputs": [], + "source": [ + "xyz_tri[\"Incurred\"].dev_to_val()" + ] + }, + { + "cell_type": "markdown", + "id": "6e404747-8e22-42c0-a1b5-45c95d702730", + "metadata": {}, + "source": [ + "Another function that is often useful is the `.heatmap()` method. Let's inspect the incurred amount and see if there are trends." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f20ed887-e5b1-40f7-81b5-14bd840cca23", + "metadata": {}, +<<<<<<< HEAD + "outputs": [], +======= "outputs": [ { "data": { "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + "\n", + "
1224364860728496108120132
1998
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -721,12 +805,12 @@ " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -735,11 +819,11 @@ " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -749,10 +833,10 @@ " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -763,9 +847,9 @@ " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -777,8 +861,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -791,2016 +875,259 @@ " \n", " \n", " \n", - "
 1224364860728496108120132
19986,3098,52110,08211,62013,24214,41915,31115,76415,82211,17112,38013,21614,06714,68816,36616,16315,83515,822
199919994,6669,86113,97118,12722,03223,51124,14624,59224,81713,25516,40519,63922,47323,76425,09424,79525,07125,107
20001,3026,51312,13917,82824,03028,85333,22235,90236,782200015,67618,74921,90027,14429,48834,45836,94937,50537,246
20011,5395,95212,31918,60924,38731,09037,07038,519200111,82716,00421,02226,57834,20537,13638,54138,798
20022,3187,93213,82222,09531,94540,62944,437200212,81120,37026,65637,66744,41448,70148,169
20031,7436,24012,68322,89234,50539,32020039,65116,99530,35440,59444,23144,373
20042,2219,89825,95043,43952,811200416,99540,18058,86671,70770,288
20053,04312,21927,07340,026200528,67447,43270,34070,655
20063,53111,77822,819200627,06646,78348,804
20073,52911,865200719,47731,732
20083,409200818,632
" + "\n" ], "text/plain": [ - " 12 24 36 48 60 72 84 96 108 120 132\n", - "1998 NaN NaN 6309.0 8521.0 10082.0 11620.0 13242.0 14419.0 15311.0 15764.0 15822.0\n", - "1999 NaN 4666.0 9861.0 13971.0 18127.0 22032.0 23511.0 24146.0 24592.0 24817.0 NaN\n", - "2000 1302.0 6513.0 12139.0 17828.0 24030.0 28853.0 33222.0 35902.0 36782.0 NaN NaN\n", - "2001 1539.0 5952.0 12319.0 18609.0 24387.0 31090.0 37070.0 38519.0 NaN NaN NaN\n", - "2002 2318.0 7932.0 13822.0 22095.0 31945.0 40629.0 44437.0 NaN NaN NaN NaN\n", - "2003 1743.0 6240.0 12683.0 22892.0 34505.0 39320.0 NaN NaN NaN NaN NaN\n", - "2004 2221.0 9898.0 25950.0 43439.0 52811.0 NaN NaN NaN NaN NaN NaN\n", - "2005 3043.0 12219.0 27073.0 40026.0 NaN NaN NaN NaN NaN NaN NaN\n", - "2006 3531.0 11778.0 22819.0 NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2007 3529.0 11865.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2008 3409.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN" + "" ] }, - "execution_count": 9, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], +>>>>>>> c23481473ff4beacbcca9e4b5243e2f78b4b5b08 "source": [ - "xyz_tri[\"Paid\"]" + "xyz_tri[\"Incurred\"].heatmap()" ] }, { "cell_type": "markdown", - "id": "04114ff8-107a-4c56-ab9a-8c36f53553df", + "id": "27d110d2-ee73-4bb5-a411-3d27c0dd7673", "metadata": {}, "source": [ - "# Pandas-like Operations" + "# Development" ] }, { "cell_type": "markdown", - "id": "433b8ae8-1968-4dfc-a176-c8a8c93c5f97", + "id": "a0d0950f-bec7-406d-b253-4cf1bfd925dd", "metadata": {}, "source": [ - "Let's see how `.iloc[...]` and `.loc[...]` similarly to pandas. They take 4 parameters: [index, column, origin, valuation]." + "How can we get the incurred link ratios?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ec16d0fd-ac17-4280-aabf-ad5795114d5f", + "metadata": {}, + "outputs": [], + "source": [ + "xyz_tri[\"Incurred\"].link_ratio" ] }, { "cell_type": "markdown", - "id": "f0452527-796d-4185-929a-97241329b377", + "id": "c74c5352-a95b-4403-8322-962ded312e39", "metadata": {}, "source": [ - "What if we want the row from AY 1998 Incurred data?" + "We can also apply a `.heatmap()` to make it too, to help us visulize the highs and lows." ] }, { "cell_type": "code", - "execution_count": 10, - "id": "a13a157b-3fe9-4254-bc72-11d4e1705f29", + "execution_count": null, + "id": "172c70be-2324-472f-b89c-29963695179a", "metadata": {}, +<<<<<<< HEAD + "outputs": [], +======= "outputs": [ { "data": { "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
1224364860728496108120132
199811,17112,38013,21614,06714,68816,36616,16315,83515,822
" - ], - "text/plain": [ - " 12 24 36 48 60 72 84 96 108 120 132\n", - "1998 NaN NaN 11171.0 12380.0 13216.0 14067.0 14688.0 16366.0 16163.0 15835.0 15822.0" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xyz_tri.iloc[:, 0, 0, :]" - ] - }, - { - "cell_type": "markdown", - "id": "08b8557c-66fe-4a25-a8bf-5413ca1c1fbb", - "metadata": {}, - "source": [ - "What if you only want the valuation at age 60 of AY 1998?" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "fb20eda1-4e4a-431d-8c8a-21cc87b8c472", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
60
199813,216
" - ], - "text/plain": [ - " 60\n", - "1998 13216.0" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xyz_tri.iloc[:, 0, 0, 4]" - ] - }, - { - "cell_type": "markdown", - "id": "56683ffb-01ef-4e18-ba27-1b8ab31b9ae7", - "metadata": {}, - "source": [ - "Let's use `.loc[...]` to get the incurred triangle." - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "b8116ded-c788-483c-b2af-fde45b72ee4a", - "metadata": { - "tags": [] - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
1224364860728496108120132
199811,17112,38013,21614,06714,68816,36616,16315,83515,822
199913,25516,40519,63922,47323,76425,09424,79525,07125,107
200015,67618,74921,90027,14429,48834,45836,94937,50537,246
200111,82716,00421,02226,57834,20537,13638,54138,798
200212,81120,37026,65637,66744,41448,70148,169
20039,65116,99530,35440,59444,23144,373
200416,99540,18058,86671,70770,288
200528,67447,43270,34070,655
200627,06646,78348,804
200719,47731,732
200818,632
" - ], - "text/plain": [ - " 12 24 36 48 60 72 84 96 108 120 132\n", - "1998 NaN NaN 11171.0 12380.0 13216.0 14067.0 14688.0 16366.0 16163.0 15835.0 15822.0\n", - "1999 NaN 13255.0 16405.0 19639.0 22473.0 23764.0 25094.0 24795.0 25071.0 25107.0 NaN\n", - "2000 15676.0 18749.0 21900.0 27144.0 29488.0 34458.0 36949.0 37505.0 37246.0 NaN NaN\n", - "2001 11827.0 16004.0 21022.0 26578.0 34205.0 37136.0 38541.0 38798.0 NaN NaN NaN\n", - "2002 12811.0 20370.0 26656.0 37667.0 44414.0 48701.0 48169.0 NaN NaN NaN NaN\n", - "2003 9651.0 16995.0 30354.0 40594.0 44231.0 44373.0 NaN NaN NaN NaN NaN\n", - "2004 16995.0 40180.0 58866.0 71707.0 70288.0 NaN NaN NaN NaN NaN NaN\n", - "2005 28674.0 47432.0 70340.0 70655.0 NaN NaN NaN NaN NaN NaN NaN\n", - "2006 27066.0 46783.0 48804.0 NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2007 19477.0 31732.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2008 18632.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xyz_tri.loc[:, \"Incurred\", :, :]" - ] - }, - { - "cell_type": "markdown", - "id": "c9d515b7-c9a3-4045-ad79-78af1574be8a", - "metadata": {}, - "source": [ - "How do we get the latest Incurred diagonal only?" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "5bce08b8-bf34-418e-ac3b-db253db44898", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
2008
199815,822
199925,107
200037,246
200138,798
200248,169
200344,373
200470,288
200570,655
200648,804
200731,732
200818,632
" - ], - "text/plain": [ - " 2008\n", - "1998 15822.0\n", - "1999 25107.0\n", - "2000 37246.0\n", - "2001 38798.0\n", - "2002 48169.0\n", - "2003 44373.0\n", - "2004 70288.0\n", - "2005 70655.0\n", - "2006 48804.0\n", - "2007 31732.0\n", - "2008 18632.0" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xyz_tri[\"Incurred\"].latest_diagonal" - ] - }, - { - "cell_type": "markdown", - "id": "31b56210-cbcd-4bbb-af9f-063a3788867a", - "metadata": {}, - "source": [ - "Very often, we want incremental triangles instead. Let's convert the Incurred triangle to the incremental form." - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "b2766e7b-b1e6-4574-bfa7-fd70ccd556d7", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
1224364860728496108120132
199811,1711,2098368516211,678-203-328-13
199913,2553,1503,2342,8341,2911,330-29927636
200015,6763,0733,1515,2442,3444,9702,491556-259
200111,8274,1775,0185,5567,6272,9311,405257
200212,8117,5596,28611,0116,7474,287-532
20039,6517,34413,35910,2403,637142
200416,99523,18518,68612,841-1,419
200528,67418,75822,908315
200627,06619,7172,021
200719,47712,255
200818,632
" - ], - "text/plain": [ - " 12 24 36 48 60 72 84 96 108 120 132\n", - "1998 NaN NaN 11171.0 1209.0 836.0 851.0 621.0 1678.0 -203.0 -328.0 -13.0\n", - "1999 NaN 13255.0 3150.0 3234.0 2834.0 1291.0 1330.0 -299.0 276.0 36.0 NaN\n", - "2000 15676.0 3073.0 3151.0 5244.0 2344.0 4970.0 2491.0 556.0 -259.0 NaN NaN\n", - "2001 11827.0 4177.0 5018.0 5556.0 7627.0 2931.0 1405.0 257.0 NaN NaN NaN\n", - "2002 12811.0 7559.0 6286.0 11011.0 6747.0 4287.0 -532.0 NaN NaN NaN NaN\n", - "2003 9651.0 7344.0 13359.0 10240.0 3637.0 142.0 NaN NaN NaN NaN NaN\n", - "2004 16995.0 23185.0 18686.0 12841.0 -1419.0 NaN NaN NaN NaN NaN NaN\n", - "2005 28674.0 18758.0 22908.0 315.0 NaN NaN NaN NaN NaN NaN NaN\n", - "2006 27066.0 19717.0 2021.0 NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2007 19477.0 12255.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2008 18632.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xyz_tri[\"Incurred\"].cum_to_incr()" - ] - }, - { - "cell_type": "markdown", - "id": "6235668f-9025-4108-b987-f867f93c8ce6", - "metadata": {}, - "source": [ - "We can also convert the triangle to the valuation format, what we often see on Schedule Ps." - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "id": "72487c9a-4438-4ab7-8a24-245485d4c637", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
19981999200020012002200320042005200620072008
199811,17112,38013,21614,06714,68816,36616,16315,83515,822
199913,25516,40519,63922,47323,76425,09424,79525,07125,107
200015,67618,74921,90027,14429,48834,45836,94937,50537,246
200111,82716,00421,02226,57834,20537,13638,54138,798
200212,81120,37026,65637,66744,41448,70148,169
20039,65116,99530,35440,59444,23144,373
200416,99540,18058,86671,70770,288
200528,67447,43270,34070,655
200627,06646,78348,804
200719,47731,732
200818,632
" - ], - "text/plain": [ - " 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008\n", - "1998 NaN NaN 11171.0 12380.0 13216.0 14067.0 14688.0 16366.0 16163.0 15835.0 15822.0\n", - "1999 NaN NaN 13255.0 16405.0 19639.0 22473.0 23764.0 25094.0 24795.0 25071.0 25107.0\n", - "2000 NaN NaN 15676.0 18749.0 21900.0 27144.0 29488.0 34458.0 36949.0 37505.0 37246.0\n", - "2001 NaN NaN NaN 11827.0 16004.0 21022.0 26578.0 34205.0 37136.0 38541.0 38798.0\n", - "2002 NaN NaN NaN NaN 12811.0 20370.0 26656.0 37667.0 44414.0 48701.0 48169.0\n", - "2003 NaN NaN NaN NaN NaN 9651.0 16995.0 30354.0 40594.0 44231.0 44373.0\n", - "2004 NaN NaN NaN NaN NaN NaN 16995.0 40180.0 58866.0 71707.0 70288.0\n", - "2005 NaN NaN NaN NaN NaN NaN NaN 28674.0 47432.0 70340.0 70655.0\n", - "2006 NaN NaN NaN NaN NaN NaN NaN NaN 27066.0 46783.0 48804.0\n", - "2007 NaN NaN NaN NaN NaN NaN NaN NaN NaN 19477.0 31732.0\n", - "2008 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 18632.0" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xyz_tri[\"Incurred\"].dev_to_val()" - ] - }, - { - "cell_type": "markdown", - "id": "6e404747-8e22-42c0-a1b5-45c95d702730", - "metadata": {}, - "source": [ - "Another function that is often useful is the `.heatmap()` method. Let's inspect the incurred amount and see if there are trends." - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "f20ed887-e5b1-40f7-81b5-14bd840cca23", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
 1224364860728496108120132
199811,17112,38013,21614,06714,68816,36616,16315,83515,822
199913,25516,40519,63922,47323,76425,09424,79525,07125,107
200015,67618,74921,90027,14429,48834,45836,94937,50537,246
200111,82716,00421,02226,57834,20537,13638,54138,798
200212,81120,37026,65637,66744,41448,70148,169
20039,65116,99530,35440,59444,23144,373
200416,99540,18058,86671,70770,288
200528,67447,43270,34070,655
200627,06646,78348,804
200719,47731,732
200818,632
\n" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xyz_tri[\"Incurred\"].heatmap()" - ] - }, - { - "cell_type": "markdown", - "id": "27d110d2-ee73-4bb5-a411-3d27c0dd7673", - "metadata": {}, - "source": [ - "# Development" - ] - }, - { - "cell_type": "markdown", - "id": "a0d0950f-bec7-406d-b253-4cf1bfd925dd", - "metadata": {}, - "source": [ - "How can we get the incurred link ratios?" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "id": "ec16d0fd-ac17-4280-aabf-ad5795114d5f", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
12-2424-3636-4848-6060-7272-8484-9696-108108-120120-132
19981.10821.06751.06441.04411.11420.98760.97970.9992
19991.23761.19711.14431.05741.05600.98811.01111.0014
20001.19601.16811.23951.08641.16851.07231.01500.9931
20011.35321.31351.26431.28701.08571.03781.0067
20021.59001.30861.41311.17911.09650.9891
20031.76101.78611.33741.08961.0032
20042.36421.46511.21810.9802
20051.65421.48301.0045
20061.72851.0432
20071.6292
" - ], - "text/plain": [ - " 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120 120-132\n", - "1998 NaN NaN 1.108227 1.067528 1.064392 1.044146 1.114243 0.987596 0.979707 0.999179\n", - "1999 NaN 1.237646 1.197135 1.144305 1.057447 1.055967 0.988085 1.011131 1.001436 NaN\n", - "2000 1.196032 1.168062 1.239452 1.086354 1.168543 1.072291 1.015048 0.993094 NaN NaN\n", - "2001 1.353175 1.313547 1.264295 1.286967 1.085689 1.037834 1.006668 NaN NaN NaN\n", - "2002 1.590040 1.308591 1.413078 1.179122 1.096524 0.989076 NaN NaN NaN NaN\n", - "2003 1.760957 1.786055 1.337353 1.089595 1.003210 NaN NaN NaN NaN NaN\n", - "2004 2.364225 1.465057 1.218140 0.980211 NaN NaN NaN NaN NaN NaN\n", - "2005 1.654181 1.482965 1.004478 NaN NaN NaN NaN NaN NaN NaN\n", - "2006 1.728479 1.043199 NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2007 1.629204 NaN NaN NaN NaN NaN NaN NaN NaN NaN" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xyz_tri[\"Incurred\"].link_ratio" - ] - }, - { - "cell_type": "markdown", - "id": "c74c5352-a95b-4403-8322-962ded312e39", - "metadata": {}, - "source": [ - "We can also apply a `.heatmap()` to make it too, to help us visulize the highs and lows." - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "172c70be-2324-472f-b89c-29963695179a", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
 12-2424-3636-4848-6060-7272-8484-9696-108108-120120-132
19981.10821.06751.06441.04411.11420.98760.97970.9992
19991.23761.19711.14431.05741.05600.98811.01111.0014
20001.19601.16811.23951.08641.16851.07231.01500.9931
20011.35321.31351.26431.28701.08571.03781.0067
20021.59001.30861.41311.17911.09650.9891
20031.76101.78611.33741.08961.0032
20042.36421.46511.21810.9802
20051.65421.48301.0045
20061.72851.0432
20071.6292
\n" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xyz_tri[\"Incurred\"].link_ratio.heatmap()" - ] - }, - { - "cell_type": "markdown", - "id": "f5f212b0-3769-49cd-b7cc-b484f2877aa2", - "metadata": {}, - "source": [ - "Let's get a volume-weighted average LDFs for our Incurred triangle." - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "id": "ba0b96cb-77eb-472c-84fd-c5c8c5c11e10", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
12-2424-3636-4848-6060-7272-8484-9696-108108-120120-132
(All)1.65951.35061.22281.11921.07931.03991.03100.99730.99060.9992
" - ], - "text/plain": [ - " 12-24 24-36 36-48 48-60 60-72 72-84 84-96 96-108 108-120 120-132\n", - "(All) 1.659537 1.35064 1.22277 1.119155 1.079301 1.039863 1.031011 0.997274 0.990571 0.999179" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cl.Development(average=\"volume\").fit(xyz_tri[\"Incurred\"]).ldf_" - ] - }, - { - "cell_type": "markdown", - "id": "0c4baafd-e141-4566-a4ae-2f0a44ef828e", - "metadata": {}, - "source": [ - "How about the CDFs?" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "id": "b156f84b-dd0d-49d6-8eec-070d0143f40c", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
12-Ult24-Ult36-Ult48-Ult60-Ult72-Ult84-Ult96-Ult108-Ult120-Ult
(All)3.50342.11111.56301.27821.14221.05821.01770.98710.98980.9992
" - ], - "text/plain": [ - " 12-Ult 24-Ult 36-Ult 48-Ult 60-Ult 72-Ult 84-Ult 96-Ult 108-Ult 120-Ult\n", - "(All) 3.503374 2.111056 1.563004 1.278249 1.142156 1.058237 1.01767 0.98706 0.989758 0.999179" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cl.Development(average=\"volume\").fit(xyz_tri[\"Incurred\"]).cdf_" - ] - }, - { - "cell_type": "markdown", - "id": "d51e5664-3106-41d1-b77f-8afa9ee94ff7", - "metadata": {}, - "source": [ - "We can also use only the latest 3 periods in the calculation of CDFs." - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "id": "de88fdad-5d89-4cc2-adb0-bbeb7c77bbcb", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", + "\n", + "
\n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
12-Ult24-Ult36-Ult48-Ult60-Ult72-Ult84-Ult96-Ult108-Ult120-Ult
(All)3.10271.85721.39601.17641.08631.02300.99030.98710.98980.9992
" - ], - "text/plain": [ - " 12-Ult 24-Ult 36-Ult 48-Ult 60-Ult 72-Ult 84-Ult 96-Ult 108-Ult 120-Ult\n", - "(All) 3.102708 1.857218 1.395977 1.176395 1.086262 1.02303 0.990285 0.98706 0.989758 0.999179" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cl.Development(average=\"volume\", n_periods=3).fit(xyz_tri[\"Incurred\"]).cdf_" - ] - }, - { - "cell_type": "markdown", - "id": "b018bae9-6070-4795-8af6-b5e196aa1af1", - "metadata": {}, - "source": [ - "# Deterministic Models" - ] - }, - { - "cell_type": "markdown", - "id": "e7c7b88e-205d-45c8-b9e6-4586f29041a4", - "metadata": {}, - "source": [ - "Before we can build any models, we need to use `fit_transform()`, so that the object is actually modified with our selected development pattern(s).\n", - "\n", - "Set the development of the triangle to use only 3 periods." - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "id": "9e5136d2-0c3c-44da-8440-57ca3cfbbb9d", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", " \n", " \n", " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2810,10 +1137,9 @@ " \n", " \n", " \n", - " \n", - " \n", - " \n", - " \n", + " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2824,9 +1150,8 @@ " \n", " \n", " \n", - " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -2838,253 +1163,155 @@ " \n", " \n", " \n", - "
1224364860728496108120132 12-2424-3636-4848-6060-7272-8484-9696-108108-120120-132
199811,17112,38013,21614,06714,68816,36616,16315,83515,822
1999199813,25516,40519,63922,47323,76425,09424,79525,07125,1071.10821.06751.06441.04411.11420.98760.97970.9992
200015,67618,74921,90027,14429,48834,45836,94937,50537,24619991.23761.19711.14431.05741.05600.98811.01111.0014
200111,82716,00421,02226,57834,20537,13638,54138,79820001.19601.16811.23951.08641.16851.07231.01500.9931
200212,81120,37026,65637,66744,41448,70148,16920011.35321.31351.26431.28701.08571.03781.0067
20039,65116,99530,35440,59444,23144,37320021.59001.30861.41311.17911.09650.9891
200416,99540,18058,86671,70770,28820031.76101.78611.33741.08961.0032
200528,67447,43270,34070,655
20042.36421.46511.21810.9802
200627,06646,78348,80420051.65421.48301.0045
200719,47731,73220061.72851.0432
200818,63220071.6292
" + "\n" ], "text/plain": [ - " 12 24 36 48 60 72 84 96 108 120 132\n", - "1998 NaN NaN 11171.0 12380.0 13216.0 14067.0 14688.0 16366.0 16163.0 15835.0 15822.0\n", - "1999 NaN 13255.0 16405.0 19639.0 22473.0 23764.0 25094.0 24795.0 25071.0 25107.0 NaN\n", - "2000 15676.0 18749.0 21900.0 27144.0 29488.0 34458.0 36949.0 37505.0 37246.0 NaN NaN\n", - "2001 11827.0 16004.0 21022.0 26578.0 34205.0 37136.0 38541.0 38798.0 NaN NaN NaN\n", - "2002 12811.0 20370.0 26656.0 37667.0 44414.0 48701.0 48169.0 NaN NaN NaN NaN\n", - "2003 9651.0 16995.0 30354.0 40594.0 44231.0 44373.0 NaN NaN NaN NaN NaN\n", - "2004 16995.0 40180.0 58866.0 71707.0 70288.0 NaN NaN NaN NaN NaN NaN\n", - "2005 28674.0 47432.0 70340.0 70655.0 NaN NaN NaN NaN NaN NaN NaN\n", - "2006 27066.0 46783.0 48804.0 NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2007 19477.0 31732.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n", - "2008 18632.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN" + "" ] }, - "execution_count": 22, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], +>>>>>>> c23481473ff4beacbcca9e4b5243e2f78b4b5b08 "source": [ - "cl.Development(n_periods=3).fit_transform(xyz_tri[\"Incurred\"])" + "xyz_tri[\"Incurred\"].link_ratio.heatmap()" ] }, { "cell_type": "markdown", - "id": "1bd89481-e5c7-4a84-b2cc-a2e386ccdb15", + "id": "f5f212b0-3769-49cd-b7cc-b484f2877aa2", "metadata": {}, "source": [ - "Let's fit a chainladder model to our Incurred triangle." + "Let's get a volume-weighted average LDFs for our Incurred triangle." ] }, { "cell_type": "code", - "execution_count": 23, - "id": "022e22e9-92a8-427c-bf5c-cf352df1437c", + "execution_count": null, + "id": "ba0b96cb-77eb-472c-84fd-c5c8c5c11e10", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
Chainladder()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" - ], - "text/plain": [ - "Chainladder()" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "cl_mod = cl.Chainladder().fit(xyz_tri[\"Incurred\"])\n", - "cl_mod" + "cl.Development(average=\"volume\").fit(xyz_tri[\"Incurred\"]).ldf_" ] }, { "cell_type": "markdown", - "id": "7b710342-5f86-408e-bf7e-76382b37f2d1", + "id": "0c4baafd-e141-4566-a4ae-2f0a44ef828e", "metadata": {}, "source": [ - "How can we get the model's ultimate estimate?" + "How about the CDFs?" ] }, { "cell_type": "code", - "execution_count": 24, - "id": "69f18923-73b1-4b80-9148-60a7bab5b118", + "execution_count": null, + "id": "b156f84b-dd0d-49d6-8eec-070d0143f40c", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
2261
199815,822
199925,086
200036,952
200138,401
200248,582
200346,258
200478,914
200586,933
200671,662
200762,406
200861,402
" - ], - "text/plain": [ - " 2261\n", - "1998 15822.000000\n", - "1999 25086.388001\n", - "2000 36951.879990\n", - "2001 38400.613702\n", - "2002 48582.226476\n", - "2003 46257.941381\n", - "2004 78913.510138\n", - "2005 86933.374265\n", - "2006 71661.720703\n", - "2007 62405.722716\n", - "2008 61401.770743" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "cl_mod.ultimate_" + "cl.Development(average=\"volume\").fit(xyz_tri[\"Incurred\"]).cdf_" ] }, { "cell_type": "markdown", - "id": "b416a404-8d0f-46fc-a3e7-f5b5b884b4b4", + "id": "d51e5664-3106-41d1-b77f-8afa9ee94ff7", "metadata": {}, "source": [ - "How about just the IBNR?" + "We can also use only the latest 3 periods in the calculation of CDFs." ] }, { "cell_type": "code", - "execution_count": 25, - "id": "5fad3aa0-03bc-4f84-a8b7-1a00dbdebe8d", + "execution_count": null, + "id": "de88fdad-5d89-4cc2-adb0-bbeb7c77bbcb", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
2261
1998
1999-21
2000-294
2001-397
2002413
20031,885
20048,626
200516,278
200622,858
200730,674
200842,770
" - ], - "text/plain": [ - " 2261\n", - "1998 NaN\n", - "1999 -20.611999\n", - "2000 -294.120010\n", - "2001 -397.386298\n", - "2002 413.226476\n", - "2003 1884.941381\n", - "2004 8625.510138\n", - "2005 16278.374265\n", - "2006 22857.720703\n", - "2007 30673.722716\n", - "2008 42769.770743" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], + "source": [ + "cl.Development(average=\"volume\", n_periods=3).fit(xyz_tri[\"Incurred\"]).cdf_" + ] + }, + { + "cell_type": "markdown", + "id": "b018bae9-6070-4795-8af6-b5e196aa1af1", + "metadata": {}, + "source": [ + "# Deterministic Models" + ] + }, + { + "cell_type": "markdown", + "id": "e7c7b88e-205d-45c8-b9e6-4586f29041a4", + "metadata": {}, + "source": [ + "Before we can build any models, we need to use `fit_transform()`, so that the object is actually modified with our selected development pattern(s).\n", + "\n", + "Set the development of the triangle to use only 3 periods." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9e5136d2-0c3c-44da-8440-57ca3cfbbb9d", + "metadata": {}, + "outputs": [], + "source": [ + "cl.Development(n_periods=3).fit_transform(xyz_tri[\"Incurred\"])" + ] + }, + { + "cell_type": "markdown", + "id": "1bd89481-e5c7-4a84-b2cc-a2e386ccdb15", + "metadata": {}, + "source": [ + "Let's fit a chainladder model to our Incurred triangle." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "022e22e9-92a8-427c-bf5c-cf352df1437c", + "metadata": {}, + "outputs": [], + "source": [ + "cl_mod = cl.Chainladder().fit(xyz_tri[\"Incurred\"])\n", + "cl_mod" + ] + }, + { + "cell_type": "markdown", + "id": "7b710342-5f86-408e-bf7e-76382b37f2d1", + "metadata": {}, + "source": [ + "How can we get the model's ultimate estimate?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "69f18923-73b1-4b80-9148-60a7bab5b118", + "metadata": {}, + "outputs": [], + "source": [ + "cl_mod.ultimate_" + ] + }, + { + "cell_type": "markdown", + "id": "b416a404-8d0f-46fc-a3e7-f5b5b884b4b4", + "metadata": {}, + "source": [ + "How about just the IBNR?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5fad3aa0-03bc-4f84-a8b7-1a00dbdebe8d", + "metadata": {}, + "outputs": [], "source": [ "cl_mod.ibnr_" ] @@ -3099,88 +1326,10 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "id": "22eba9fa-1890-4f6f-8a10-281142d2d58d", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
2261
199818,000
199928,350
200040,500
200145,000
200255,065
200362,258
200489,390
2005124,336
200696,820
200756,194
200843,017
" - ], - "text/plain": [ - " 2261\n", - "1998 18000.0\n", - "1999 28350.0\n", - "2000 40500.0\n", - "2001 45000.0\n", - "2002 55064.7\n", - "2003 62257.5\n", - "2004 89389.8\n", - "2005 124335.9\n", - "2006 96820.2\n", - "2007 56194.2\n", - "2008 43017.3" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "cl.ExpectedLoss(apriori=0.90).fit(\n", " xyz_tri[\"Incurred\"], sample_weight=xyz_tri[\"Premium\"].latest_diagonal\n", @@ -3197,88 +1346,10 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "id": "411f48b0-8b86-4175-80f2-f5f4a19e6c46", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
2261
199818,000
199928,350
200040,500
200145,000
200255,065
200362,258
200489,390
2005124,336
200696,820
200756,194
200843,017
" - ], - "text/plain": [ - " 2261\n", - "1998 18000.0\n", - "1999 28350.0\n", - "2000 40500.0\n", - "2001 45000.0\n", - "2002 55064.7\n", - "2003 62257.5\n", - "2004 89389.8\n", - "2005 124335.9\n", - "2006 96820.2\n", - "2007 56194.2\n", - "2008 43017.3" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "cl.ExpectedLoss(apriori=0.90).fit(\n", " xyz_tri[\"Paid\"], sample_weight=xyz_tri[\"Premium\"].latest_diagonal\n", @@ -3295,186 +1366,30 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": null, "id": "d66c7c9a-71eb-4d56-beea-f275da062fc0", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
2261
199815,822
199925,084
200036,924
200138,332
200248,637
200346,910
200480,059
200593,937
200679,686
200759,353
200848,596
" - ], - "text/plain": [ - " 2261\n", - "1998 15822.000000\n", - "1999 25083.706485\n", - "2000 36923.638582\n", - "2001 38332.320375\n", - "2002 48637.364535\n", - "2003 46909.899276\n", - "2004 80058.603599\n", - "2005 93937.040205\n", - "2006 79686.444188\n", - "2007 59352.628911\n", - "2008 48595.957663" - ] - }, - "execution_count": 28, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "cl.BornhuetterFerguson(apriori=0.90).fit(\n", " xyz_tri[\"Incurred\"], sample_weight=xyz_tri[\"Premium\"].latest_diagonal\n", - ").ultimate_" - ] - }, - { - "cell_type": "markdown", - "id": "5564ead9-d059-4d2c-839a-f988238e50ee", - "metadata": {}, - "source": [ - "How about Benktander, with 1 iteration, which is the same as BF?" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "id": "d504e48d-1f5d-4fd6-975b-155235ffb577", - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
2261
199815,822
199925,084
200036,924
200138,332
200248,637
200346,910
200480,059
200593,937
200679,686
200759,353
200848,596
" - ], - "text/plain": [ - " 2261\n", - "1998 15822.000000\n", - "1999 25083.706485\n", - "2000 36923.638582\n", - "2001 38332.320375\n", - "2002 48637.364535\n", - "2003 46909.899276\n", - "2004 80058.603599\n", - "2005 93937.040205\n", - "2006 79686.444188\n", - "2007 59352.628911\n", - "2008 48595.957663" - ] - }, - "execution_count": 29, - "metadata": {}, - "output_type": "execute_result" - } - ], + ").ultimate_" + ] + }, + { + "cell_type": "markdown", + "id": "5564ead9-d059-4d2c-839a-f988238e50ee", + "metadata": {}, + "source": [ + "How about Benktander, with 1 iteration, which is the same as BF?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d504e48d-1f5d-4fd6-975b-155235ffb577", + "metadata": {}, + "outputs": [], "source": [ "cl.Benktander(apriori=0.90, n_iters=1).fit(\n", " xyz_tri[\"Incurred\"], sample_weight=xyz_tri[\"Premium\"].latest_diagonal\n", @@ -3491,88 +1406,10 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "id": "7089ea42-ad28-4edc-9e83-723a7bc25443", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
2261
199815,822
199925,087
200036,975
200138,407
200248,562
200346,504
200478,496
200590,214
200674,748
200754,936
200843,804
" - ], - "text/plain": [ - " 2261\n", - "1998 15822.000000\n", - "1999 25087.431508\n", - "2000 36975.189569\n", - "2001 38406.790341\n", - "2002 48562.465206\n", - "2003 46504.206620\n", - "2004 78496.120544\n", - "2005 90213.852284\n", - "2006 74747.824455\n", - "2007 54935.628037\n", - "2008 43804.219299" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "cl.CapeCod().fit(\n", " xyz_tri[\"Incurred\"], sample_weight=xyz_tri[\"Premium\"].latest_diagonal\n", @@ -3589,9 +1426,12 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "id": "f2cd9f8c-454d-4b9f-b936-a2f39e8fefde", "metadata": {}, +<<<<<<< HEAD + "outputs": [], +======= "outputs": [ { "data": { @@ -3614,6 +1454,7 @@ "output_type": "display_data" } ], +>>>>>>> c23481473ff4beacbcca9e4b5243e2f78b4b5b08 "source": [ "cc_result = (\n", " cl.CapeCod()\n", @@ -3644,24 +1485,10 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": null, "id": "e008ebdb-243d-4ed0-9256-86331df1070a", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
MackChainladder()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
" - ], - "text/plain": [ - "MackChainladder()" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "mcl_mod = cl.MackChainladder().fit(xyz_tri[\"Incurred\"])\n", "mcl_mod" @@ -3677,208 +1504,10 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "id": "67f5d99b-7a5e-4640-a6e0-f8b654e6ce27", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
1224364860728496108120132
19980.00000.00000.24500.17410.08860.05370.06090.01460.01690.01100.0000
19990.00000.30440.20220.13820.06790.04130.04660.01180.01360.00870.0000
20000.32430.25590.17500.11760.05930.03430.03840.00960.01120.00720.0000
20010.37340.27700.17860.11880.05500.03300.03760.00950.01090.00700.0000
20020.35870.24550.15860.09980.04830.02890.03370.00840.00970.00630.0000
20030.41330.26880.14870.09610.04840.03020.03450.00860.01000.00640.0000
20040.31150.17480.10670.07230.03840.02310.02640.00660.00760.00490.0000
20050.23980.16090.09770.07290.03660.02210.02520.00630.00730.00470.0000
20060.24680.16200.11720.08030.04030.02430.02770.00690.00800.00520.0000
20070.29090.19670.12560.08600.04320.02600.02970.00740.00860.00550.0000
20080.29750.19830.12670.08670.04350.02620.02990.00750.00870.00560.0000
" - ], - "text/plain": [ - " 12 24 36 48 60 72 84 96 108 120 132\n", - "1998 0.000000 0.000000 0.245040 0.174079 0.088551 0.053698 0.060944 0.014560 0.016943 0.010981 0.0\n", - "1999 0.000000 0.304387 0.202207 0.138212 0.067907 0.041314 0.046626 0.011829 0.013604 0.008721 0.0\n", - "2000 0.324294 0.255933 0.175009 0.117563 0.059282 0.034309 0.038425 0.009618 0.011162 0.007186 0.0\n", - "2001 0.373352 0.277014 0.178627 0.118808 0.055043 0.033049 0.037623 0.009456 0.010949 0.007049 0.0\n", - "2002 0.358728 0.245539 0.158630 0.099799 0.048304 0.028859 0.033653 0.008407 0.009734 0.006267 0.0\n", - "2003 0.413305 0.268816 0.148654 0.096134 0.048404 0.030234 0.034488 0.008616 0.009976 0.006422 0.0\n", - "2004 0.311455 0.174828 0.106746 0.072331 0.038398 0.023148 0.026405 0.006597 0.007638 0.004917 0.0\n", - "2005 0.239780 0.160909 0.097652 0.072868 0.036584 0.022054 0.025158 0.006285 0.007277 0.004685 0.0\n", - "2006 0.246799 0.162021 0.117235 0.080257 0.040294 0.024291 0.027709 0.006922 0.008015 0.005160 0.0\n", - "2007 0.290935 0.196728 0.125628 0.086003 0.043178 0.026030 0.029693 0.007418 0.008589 0.005529 0.0\n", - "2008 0.297459 0.198330 0.126651 0.086704 0.043530 0.026242 0.029935 0.007478 0.008659 0.005574 0.0" - ] - }, - "execution_count": 33, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "mcl_mod.full_std_err_" ] @@ -3893,124 +1522,10 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": null, "id": "81fc38c1-d5b7-4262-94ae-bce5c7ac17e1", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
LatestIBNRUltimateMack Std Err
199815,82215,822
199925,107-2125,086352
200037,246-29436,952751
200138,798-39738,401893
200248,16941348,5822,190
200344,3731,88546,2582,614
200470,2888,62678,9145,004
200570,65516,27886,9338,487
200648,80422,85871,66210,738
200731,73230,67462,40613,925
200818,63242,77061,40218,019
" - ], - "text/plain": [ - " Latest IBNR Ultimate Mack Std Err\n", - "1998 15822.0 NaN 15822.000000 NaN\n", - "1999 25107.0 -20.611999 25086.388001 352.069939\n", - "2000 37246.0 -294.120010 36951.879990 750.954565\n", - "2001 38798.0 -397.386298 38400.613702 892.719893\n", - "2002 48169.0 413.226476 48582.226476 2190.044383\n", - "2003 44373.0 1884.941381 46257.941381 2613.888360\n", - "2004 70288.0 8625.510138 78913.510138 5004.358291\n", - "2005 70655.0 16278.374265 86933.374265 8486.846704\n", - "2006 48804.0 22857.720703 71661.720703 10738.482249\n", - "2007 31732.0 30673.722716 62405.722716 13925.203501\n", - "2008 18632.0 42769.770743 61401.770743 18019.072745" - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "mcl_mod.summary_" ] @@ -4025,9 +1540,12 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": null, "id": "e615b86e-a907-4445-9e95-645090719f76", "metadata": {}, +<<<<<<< HEAD + "outputs": [], +======= "outputs": [ { "data": { @@ -4050,18 +1568,19 @@ "output_type": "display_data" } ], +>>>>>>> c23481473ff4beacbcca9e4b5243e2f78b4b5b08 "source": [ "plt.bar(\n", " mcl_mod.summary_.to_frame(origin_as_datetime=True).index.year,\n", " mcl_mod.summary_.to_frame(origin_as_datetime=True)[\"Latest\"],\n", - " label=\"Paid\",\n", + " label=\"Reported\",\n", ")\n", "plt.bar(\n", " mcl_mod.summary_.to_frame(origin_as_datetime=True).index.year,\n", " mcl_mod.summary_.to_frame(origin_as_datetime=True)[\"IBNR\"],\n", " bottom=mcl_mod.summary_.to_frame(origin_as_datetime=True)[\"Latest\"],\n", " yerr=mcl_mod.summary_.to_frame(origin_as_datetime=True)[\"Mack Std Err\"],\n", - " label=\"Reserves\",\n", + " label=\"IBNR\",\n", ")\n", "plt.legend(loc=\"upper left\")" ] @@ -4076,58 +1595,10 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": null, "id": "859e19f3-d526-435c-a845-4845a7a3956d", "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
Triangle Summary
Valuation:2008-12
Grain:OYDY
Shape:(10000, 1, 11, 11)
Index:[Total]
Columns:[Incurred]
" - ], - "text/plain": [ - " Triangle Summary\n", - "Valuation: 2008-12\n", - "Grain: OYDY\n", - "Shape: (10000, 1, 11, 11)\n", - "Index: [Total]\n", - "Columns: [Incurred]" - ] - }, - "execution_count": 36, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "xyz_tri_sampled = (\n", " cl.BootstrapODPSample(n_sims=10000).fit(xyz_tri[\"Incurred\"]).resampled_triangles_\n", @@ -4145,9 +1616,12 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": null, "id": "fe6dbe70-1b2a-4fb0-aa6b-56380534704f", "metadata": {}, +<<<<<<< HEAD + "outputs": [], +======= "outputs": [ { "name": "stderr", @@ -4183,6 +1657,7 @@ "output_type": "execute_result" } ], +>>>>>>> c23481473ff4beacbcca9e4b5243e2f78b4b5b08 "source": [ "cl_mod_bootstrapped = cl.Chainladder().fit(xyz_tri_sampled)\n", "cl_mod_bootstrapped" @@ -4198,11 +1673,14 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": null, "id": "edeba1db-97e6-43df-b1c0-590c2d7cd098", "metadata": { "tags": [] }, +<<<<<<< HEAD + "outputs": [], +======= "outputs": [ { "data": { @@ -4225,6 +1703,7 @@ "output_type": "display_data" } ], +>>>>>>> c23481473ff4beacbcca9e4b5243e2f78b4b5b08 "source": [ "plt.bar(\n", " cl_mod_bootstrapped.ultimate_.mean().to_frame(origin_as_datetime=True).index.year,\n",