Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mid-year valuations not working #225

Closed
goduckie opened this issue Nov 4, 2021 · 9 comments
Closed

mid-year valuations not working #225

goduckie opened this issue Nov 4, 2021 · 9 comments

Comments

@goduckie
Copy link

goduckie commented Nov 4, 2021

see code example below:

import chainladder as cl
import pandas as pd

raa = cl.load_sample('raa')\
    .dev_to_val()\
    .to_frame(keepdims=True)

#adjust valuations to mid-year
raa['valuation'] = raa['valuation']-raa.apply(lambda x: pd.DateOffset(**{'months': 6}), axis=1)

def kwargs(df):
    return {'data': raa.reset_index(),
            'columns': 'values',
            'origin': 'origin',
            'development': 'valuation',
            'index': 'Total',
            'cumulative': True}

#ERROR expecting tri development at 6, 18, 30 etc
tri = cl.Triangle(**kwargs(raa))

#ERROR adjusted mid-year valuations are overwritten with EOY
tri.dev_to_val().to_frame(keepdims=True)
@goduckie
Copy link
Author

goduckie commented Nov 4, 2021

a triangle with just latest diagonal works as expected:

i..e replace the first line with the following, results in development periods at 6, 18, 30 etc

raa = cl.load_sample('raa')\
    .dev_to_val()\
    .latest_diagonal\
    .to_frame(keepdims=True)

@jbogaardt
Copy link
Collaborator

This is definitely a gap in the library. OYDY grains with support for ages other than ages 12, 24, 36, etc. is spotty. This is a big problem, particularly for reinsurance or consulting where get pre-aggregated data is common. Its definitely an enhancement we need to tackle.

@goduckie
Copy link
Author

goduckie commented Nov 4, 2021

Can you please help me understand, why it even cares what the ages are?

Provided the ages are consistent between development and the triangle that is being transformed / fitted, then shouldn't the ages themselves be irrelevant? What am I not understanding?

@jbogaardt
Copy link
Collaborator

It shouldn't, but thats not the tricky part. The tricky part is that we need to accomodate two different use cases here.

  1. Yours is one that requires that the origin periods follow a January-December with an age of 6, 18, ...
  2. Others want a July-June origin period assuming age 12, 24, ...

Ensuring that enough information is obtained from the data and user to support both is something that needs to be thought out.

By the way, this one is a duplicate of #188, so it's on the list of things to do. We should close one of the duplicates out.

@AuldKingCole
Copy link

I'm actually facing this very problem right now in attempting to apply this library to my work as a reinsurer. The industry benchmarks that I'm provided are evaluated each March, with the first evaluation for a given accident year starting at 15 months. I can't for the life of me get the cl.Triangle() to produce a triangle on a 15/27/39 etc. basis. It keeps overwriting my development entries and assuming annual evaluation delays. Any advice or solutions would be greatly appreciated.

@jbogaardt
Copy link
Collaborator

@AuldKingCole, unfortunately I don't have a solution that isn't completely janky. I run into the same problem using industry data at those same valuations. I appreciate you sharing your pain point as well. The only consolation I can give is that the higher number of people wanting this functionality definitely influences its prioritization. We can prioritize it for the next release. Unfortunately that is not days/weeks in the making. Realistically it would be more like late December.

@AuldKingCole
Copy link

@jbogaardt , thanks for the response. While I see so much potential for this library in some projects I would like to establish down the line, in the meantime I only need a crisp means of batch calculating link ratios and averages. I suppose for now it won't matter if I allow the triangles to default to 12-24-36 etc? I will be very very interested in utilizing this library further if the mid-year issue ever gets worked out.

@jbogaardt
Copy link
Collaborator

@AuldKingCole, It makes me cringe that anyone would have to do that, but that should be fine for estimating LDFs.

@jbogaardt jbogaardt reopened this Nov 12, 2021
@jbogaardt
Copy link
Collaborator

A solution has been pushed to master that handles both the case where origin periods end in December and when they end at any other arbitrary month.

import chainladder as cl
import pandas as pd

raa = cl.load_sample('raa').dev_to_val().to_frame(keepdims=True).reset_index()

#adjust valuations to mid-year
raa['valuation'] = raa['valuation'] - pd.DateOffset(months=6)

print('This produces desired behavior:')
tri = cl.Triangle(raa, origin='origin', development='valuation', columns='values', cumulative=True)
print(tri)
print('Valuation Date:', tri.valuation_date, 'Close Month:', tri.origin_close)

print('What if we want our origns to run from July through June?')
raa['origin2'] = raa['origin'] - pd.DateOffset(months=6)
tri = cl.Triangle(raa, origin='origin2', development='valuation', columns='values', cumulative=True)
print(tri)
print('Valuation Date:', tri.valuation_date, 'Close Month:', tri.origin_close)

Did some lightweight testing and it all seems reasonable with no regressions on existing tests. Will do more testing over the next several weeks prior to release, but feel free to install from github if you want to play with the new functionality.

pip install git+https://github.com/casact/chainladder-python/

jbogaardt added a commit that referenced this issue Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants