diff --git a/chainladder/methods/mack.py b/chainladder/methods/mack.py index cfcf71e0..15bf820e 100644 --- a/chainladder/methods/mack.py +++ b/chainladder/methods/mack.py @@ -242,7 +242,7 @@ def _get_full_std_err_(self, X=None): val = xp.broadcast_to(xp.array(avg + [avg[-1]]), X.shape) weight = xp.sqrt(full.values[..., : len(X.ddims)] ** (2 - val)) obj.values = X.sigma_.values / num_to_nan(weight) - w = lxp.concatenate((X.w_, lxp.ones((1, 1, val.shape[2], 1))), 3) + w = lxp.concatenate((X.w_, lxp.ones((val.shape[0], val.shape[1], val.shape[2], 1))), 3) w[xp.isnan(w)] = 1 obj.values = xp.nan_to_num(obj.values) * xp.array(w) obj.valuation_date = full.valuation_date diff --git a/chainladder/methods/tests/test_mack.py b/chainladder/methods/tests/test_mack.py index c9adc020..ac9bf6c5 100644 --- a/chainladder/methods/tests/test_mack.py +++ b/chainladder/methods/tests/test_mack.py @@ -1,4 +1,5 @@ import chainladder as cl +import numpy as np def test_mack_to_triangle(): assert ( @@ -14,10 +15,16 @@ def test_mack_to_triangle(): .summary_ ) - def test_mack_malformed(): a = cl.load_sample('raa') b = a.iloc[:, :, :-1] x = cl.MackChainladder().fit(a) y = cl.MackChainladder().fit(b) - assert x.process_risk_.iloc[:,:,:-1] == y.process_risk_ \ No newline at end of file + assert x.process_risk_.iloc[:,:,:-1] == y.process_risk_ + +def test_multi_triangle_mack(clrd,atol): + tri = clrd.loc['Agway Ins Co']['IncurLoss','CumPaidLoss'] + mack = cl.MackChainladder().fit(tri) + for i in range(len(tri.index)): + for j in range(len(tri.columns)): + assert np.all(abs(mack.full_std_err_.iloc[i,j].values-cl.MackChainladder().fit(tri.iloc[i,j]).full_std_err_.values) < atol) \ No newline at end of file diff --git a/docs/friedland/chapter_7.rst b/docs/friedland/chapter_7.rst index 64f6f1b1..9b2630a8 100644 --- a/docs/friedland/chapter_7.rst +++ b/docs/friedland/chapter_7.rst @@ -27,7 +27,6 @@ PART 1 - Data Triangle We have already imported the necessary packages loading the ``Triangle`` at the top of p106. Let's take a look at the ``Triangle`` we just loaded. .. doctest:: - :hide: >>> tri = cl.load_sample('friedland_us_industry_auto') >>> tri['Reported Claims'] @@ -43,162 +42,6 @@ We have already imported the necessary packages loading the ``Triangle`` at the 2006 46582684.0 54641339.0 NaN NaN NaN NaN NaN NaN NaN NaN 2007 48853563.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN -.. code-block:: - - >>> tri = cl.load_sample('friedland_us_industry_auto') - -.. raw:: html - -
| - | 12 | -24 | -36 | -48 | -60 | -72 | -84 | -96 | -108 | -120 | -
|---|---|---|---|---|---|---|---|---|---|---|
| 1998 | -37,017,487 | -43,169,009 | -45,568,919 | -46,784,558 | -47,337,318 | -47,533,264 | -47,634,419 | -47,689,655 | -47,724,678 | -47,742,304 | -
| 1999 | -38,954,484 | -46,045,718 | -48,882,924 | -50,219,672 | -50,729,292 | -50,926,779 | -51,069,285 | -51,163,540 | -51,185,767 | -- |
| 2000 | -41,155,776 | -49,371,478 | -52,358,476 | -53,780,322 | -54,303,086 | -54,582,950 | -54,742,188 | -54,837,929 | -- | - |
| 2001 | -42,394,069 | -50,584,112 | -53,704,296 | -55,150,118 | -55,895,583 | -56,156,727 | -56,299,562 | -- | - | - |
| 2002 | -44,755,243 | -52,971,643 | -56,102,312 | -57,703,851 | -58,363,564 | -58,592,712 | -- | - | - | - |
| 2003 | -45,163,102 | -52,497,731 | -55,468,551 | -57,015,411 | -57,565,344 | -- | - | - | - | - |
| 2004 | -45,417,309 | -52,640,322 | -55,553,673 | -56,976,657 | -- | - | - | - | - | - |
| 2005 | -46,360,869 | -53,790,061 | -56,786,410 | -- | - | - | - | - | - | - |
| 2006 | -46,582,684 | -54,641,339 | -- | - | - | - | - | - | - | - |
| 2007 | -48,853,563 | -- | - | - | - | - | - | - | - | - |