Skip to content
Open
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
55 changes: 55 additions & 0 deletions chainladder/development/clark.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,61 @@ class ClarkLDF(DevelopmentBase):
norm_resid_: Triangle
The "Normalized" Residuals of the model according to Clark.

Examples
--------
Compare curve families when the selected growth curve materially affects
the fitted development pattern. The same triangle can be fit with the
default loglogistic curve or with the Weibull curve.

.. testsetup::

import chainladder as cl

.. testcode::

import numpy as np

tri = cl.load_sample("ukmotor")
m_log = cl.ClarkLDF(growth="loglogistic").fit(tri)
m_wei = cl.ClarkLDF(growth="weibull").fit(tri)
print(float(np.round(m_log.ldf_.values[0, 0, 0, 0], 3)))
print(float(np.round(m_wei.ldf_.values[0, 0, 0, 0], 3)))

.. testoutput::

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.

too close to be a worthy choice of an example

1.917
1.912

Provide exposure when the goal is a Cape Cod fit rather than a pure LDF
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.

awkward phrasing. the intentionality of the user is to use cape cod. to use cape cod, the user can pass in a weight vector without additional parameters in the clarkldf transformer.

fit. Passing ``sample_weight`` changes ``method_`` to ``cape_cod`` and
estimates ``elr_``.

.. testcode::

tri = cl.load_sample("ukmotor")
m = cl.ClarkLDF().fit(tri, sample_weight=tri * 0 + 1e7)
print(m.method_)
print(float(np.round(m.elr_.values[0, 0], 6)))

.. testoutput::

cape_cod
0.002002

Pool similar segments before fitting when each individual triangle is too
sparse for separate curve parameters. Here line of business produces one
parameter set per ``LOB``.

.. testcode::

clrd = cl.load_sample("clrd").groupby("LOB")[["IncurLoss"]].sum()
m = cl.ClarkLDF(groupby="LOB").fit(clrd)
print(m.theta_.shape)

.. testoutput::

(6, 1)
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.

the example text makes a claim about individual triangles being too sparse to fit. the actual code doesn't really make that apparent, or even show the results at all


"""

def __init__(
Expand Down
Loading