Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chainladder/methods/mack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions chainladder/methods/tests/test_mack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import chainladder as cl
import numpy as np

def test_mack_to_triangle():
assert (
Expand All @@ -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_
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)
157 changes: 0 additions & 157 deletions docs/friedland/chapter_7.rst
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What happened here? Accident?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i was trying to show gene that regular html doesn't automatically look as nice as ipynb. basically, trying to make .rst visually pleasing would be quite a feat.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ahh ok, I think I'd like a show & tell on this lol... I still don't know what's best.

Anyways I'll shut up here to not hijack the thread and let @genedan do the review.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we'll have a basis to do a comparison once you are done with your notebook recreation of chapter 8.

Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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

<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>12</th>
<th>24</th>
<th>36</th>
<th>48</th>
<th>60</th>
<th>72</th>
<th>84</th>
<th>96</th>
<th>108</th>
<th>120</th>
</tr>
</thead>
<tbody>
<tr>
<th>1998</th>
<td>37,017,487</td>
<td>43,169,009</td>
<td>45,568,919</td>
<td>46,784,558</td>
<td>47,337,318</td>
<td>47,533,264</td>
<td>47,634,419</td>
<td>47,689,655</td>
<td>47,724,678</td>
<td>47,742,304</td>
</tr>
<tr>
<th>1999</th>
<td>38,954,484</td>
<td>46,045,718</td>
<td>48,882,924</td>
<td>50,219,672</td>
<td>50,729,292</td>
<td>50,926,779</td>
<td>51,069,285</td>
<td>51,163,540</td>
<td>51,185,767</td>
<td></td>
</tr>
<tr>
<th>2000</th>
<td>41,155,776</td>
<td>49,371,478</td>
<td>52,358,476</td>
<td>53,780,322</td>
<td>54,303,086</td>
<td>54,582,950</td>
<td>54,742,188</td>
<td>54,837,929</td>
<td></td>
<td></td>
</tr>
<tr>
<th>2001</th>
<td>42,394,069</td>
<td>50,584,112</td>
<td>53,704,296</td>
<td>55,150,118</td>
<td>55,895,583</td>
<td>56,156,727</td>
<td>56,299,562</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>2002</th>
<td>44,755,243</td>
<td>52,971,643</td>
<td>56,102,312</td>
<td>57,703,851</td>
<td>58,363,564</td>
<td>58,592,712</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>2003</th>
<td>45,163,102</td>
<td>52,497,731</td>
<td>55,468,551</td>
<td>57,015,411</td>
<td>57,565,344</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>2004</th>
<td>45,417,309</td>
<td>52,640,322</td>
<td>55,553,673</td>
<td>56,976,657</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>2005</th>
<td>46,360,869</td>
<td>53,790,061</td>
<td>56,786,410</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>2006</th>
<td>46,582,684</td>
<td>54,641,339</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>2007</th>
<td>48,853,563</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>

PART 2 - Age-to-Age Factors
----------------------------

Expand Down
Loading