chainladder-python icon indicating copy to clipboard operation
chainladder-python copied to clipboard

Instatiation bug

Open jbogaardt opened this issue 3 years ago • 3 comments

offending code:

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, columns='value', origin='origin', development='val_date')

jbogaardt avatar Apr 15 '22 12:04 jbogaardt

I'm not sure if this is related to this bug, but is triangle supposed to expand the whole triangle when instantiated?

This code does not give me a triangle, but if we comment out the the first line, the triangle will be complete. This is causing some problems.

data = [
    # ["1998", "1998", 500000],
    ["1998", "2003", 500000],
    ["1999", "2003", 650000],
    ["2000", "2003", 800000],
    ["2001", "2003", 850000],
    ["2002", "2003", 975000],
    ["2003", "2003", 1000000],
]
df = pd.DataFrame(data, columns=["origin", "val_date", "value"])

cl_tri = cl.Triangle(
    data=df, origin="origin", development="val_date", columns="value", cumulative=True
)
cl_tri

kennethshsu avatar May 10 '22 05:05 kennethshsu

Hmm... I guess the triangle wouldn't know what grain to expand development to...

kennethshsu avatar May 10 '22 15:05 kennethshsu

From the above, we can use .val_to_dev(), but the expanded triangle doesn't look right, the valuation dates are coded as each year's January instead of each year's December.

kennethshsu avatar May 20 '22 21:05 kennethshsu