'Chainladder: does it work with multi-triangles with non-aligned valuation periods?

Trying to extract properties from the triangle / development class(e.g..age_to_age) give it was parameterized with multiple triangles each with different valuation dates.

This example illustrates the issue:

import chainladder as cl import pandas as pd

data = [['2010-01-01', '2011-06-30', 'premium', 100.0], ['2010-01-01', '2011-12-31', 'incurred', 100.0],
        ['2010-01-01', '2012-06-30', 'premium', 200.0], ['2010-01-01', '2012-12-31', 'incurred', 100.0],
        ['2010-01-01', '2013-12-31', 'incurred', 200.0], ['2011-01-01', '2011-06-30', 'premium', 100.0],
        ['2011-01-01', '2012-06-30', 'premium', 200.0], ['2011-01-01', '2012-12-31', 'incurred', 100.0],
        ['2011-01-01', '2013-12-31', 'incurred', 200.0], ['2012-01-01', '2012-06-30', 'premium', 200.0],
        ['2012-01-01', '2013-12-31', 'incurred', 200.0]]

df = pd.DataFrame(data, columns=['origin', 'val_date', 'idx', 'value'])

cl_tri = cl.Triangle(data=df, index='idx', columns='value', origin='origin', development='val_date', origin_grain='%Y',
                     origin_format='%Y-%m-%d', development_format='%Y-%m-%d', cumulative=True)

Then filter the Triangle to extract features but it has 'exploded' the valuation dates, and results are non-sensical:

cl_tri.iloc[0].age_to_age

cl.Development().fit_transform(cl_tri.iloc[1]).ldf_

What is the best way of dealing with this situation? Separate class objects?



Solution 1:[1]

This should just work and has been reported as a bug on the libraries code repository.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John