Skip to content

Commit

Permalink
docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogaardt committed Nov 29, 2019
1 parent f109594 commit f4f08c0
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 4 deletions.
2 changes: 1 addition & 1 deletion chainladder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from chainladder.methods import * # noqa (API Import)
from chainladder.workflow import * # noqa (API Import)

__version__ = '0.4.1'
__version__ = '0.4.2'
11 changes: 11 additions & 0 deletions chainladder/core/tests/test_triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,14 @@ def test_dropna():
clrd = cl.load_dataset('clrd')
assert clrd.shape == clrd.dropna().shape
assert clrd[clrd['LOB']=='wkcomp'].iloc[-5]['CumPaidLoss'].dropna().shape == (1,1,2,2)

def test_commutative():
tri = cl.load_dataset('quarterly')
full = cl.Chainladder().fit(tri).full_expectation_
assert tri.grain('OYDY').val_to_dev() == tri.val_to_dev().grain('OYDY')
assert tri.cum_to_incr().grain('OYDY').val_to_dev() == tri.val_to_dev().cum_to_incr().grain('OYDY')
assert tri.grain('OYDY').cum_to_incr().val_to_dev().incr_to_cum() == tri.val_to_dev().grain('OYDY')
assert full.grain('OYDY').val_to_dev() == full.val_to_dev().grain('OYDY')
assert full.cum_to_incr().grain('OYDY').val_to_dev() == full.val_to_dev().cum_to_incr().grain('OYDY')
assert np.allclose(np.nan_to_num(full.grain('OYDY').cum_to_incr().val_to_dev().incr_to_cum().values),
np.nan_to_num(full.val_to_dev().grain('OYDY').values), atol=1e-5)
1 change: 1 addition & 0 deletions docs/modules/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Classes
:template: class.rst

Development
DevelopmentConstant
MunichAdjustment
BootstrapODPSample
IncrementalAdditive
Expand Down
55 changes: 55 additions & 0 deletions docs/modules/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,39 @@ Loss Development Patterns

.. currentmodule:: chainladder

Estimators
===========

Fitting data: the main modeling API implemented by chainladder follows that of
the scikit-learn estimator. An estimator is any object that learns from data.

All estimator objects expose a fit method that takes a `Triangle()` object:

**Example:**
>>> estimator.fit(data)

Estimator parameters: All the parameters of an estimator can be set when it is
instantiated or by modifying the corresponding attribute:

**Example:**
>>> estimator = Estimator(param1=1, param2=2)
>>> estimator.param1
1

Estimated parameters: When data is fitted with an estimator, parameters are
estimated from the data at hand. All the estimated parameters are attributes
of the estimator object ending by an underscore:

**Example:**
>>> estimator.estimated_param_

In many cases the estimated paramaters are themselves triangles and can be
manipulated using the same methods we learned about in the :class:`Triangle` class.

**Example:**
>>> dev = cl.Development().fit(cl.load_dataset('ukmotor'))
>>> type(dev.cdf_)
<class 'chainladder.core.triangle.Triangle'>

.. _dev:

Expand Down Expand Up @@ -49,6 +82,28 @@ of the 'drop' arguments is permissible.
``drop_high`` and ``drop_low`` are ignored in cases where the number of link
ratios available for a given development period is less than 3.

Properties
----------
:class:`Development` uses the regression approach suggested by Mack to estimate
development patterns. Using the regression framework, we not only get estimates
for our patterns (``cdf_``, and ``ldf_``), but also measures of variability of
our estimates (``sigma_``, ``std_err_``). These variability propeperties are
used to develop the stochastic featuers in the `MackChainladder()` method.


.. _dev_const:

Constant
========

The :class:`DevelopmentConstant` method simply allows you to hard code development
patterns into a Development Estimator. A common example would be to include a
set of industry development patterns in your workflow that are not directly
estimated from any of your own data.

For more info refer to the docstring of:class:`DevelopmentConstant`.


.. _incremental:

Incremental Additive
Expand Down
17 changes: 15 additions & 2 deletions docs/modules/triangle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,35 @@ of these operations are legal.
>>> x = raa[raa.origin>'1987-01-01'][raa.development<=36]
>>> x = raa[raa.valuation<raa.valuation_date]


Valuation or development
------------------------
While most Estimators that use triangles expect the development period to be
expressed as an origin age, it is possible to transform a trianle into a valuation
triangle where the development periods are converted to valuation periods. Expressing
triangles this way may provide a more convenient view of valuation slices.
Switching between a development triangle and a valuation triangle can be
accomplished with the method `dev_to_val()` and its inverse `'val_to_dev`. For
accomplished with the method `dev_to_val()` and its inverse `'val_to_dev()`. For
example, slicing the calendar period incurred for the last two years of a
triangle in a more compact tablular format can be done as follows:

**Example:**
>>> import chainladder as cl
>>> raa = cl.load_dataset('raa').dev_to_val()
>>> raa.cum_to_incr()[raa.valuation>='1989']

1989 1990
1981 54.0 172.0
1982 673.0 535.0
1983 649.0 603.0
1984 2658.0 984.0
1985 3786.0 225.0
1986 1233.0 2917.0
1987 6926.0 1368.0
1988 5596.0 6165.0
1989 3133.0 2262.0
1990 NaN 2063.0


Commutative methods
-------------------
Where possible, the triangle methods are designed to be commutative. For example,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
descr = "Chainladder Package - P&C Loss Reserving package "
name = 'chainladder'
url = 'https://github.com/jbogaardt/chainladder-python'
version='0.4.1' # Put this in __init__.py
version='0.4.2' # Put this in __init__.py

data_path = ''
setup(
Expand Down

0 comments on commit f4f08c0

Please sign in to comment.