casact / chainladder-python

Actuarial reserving in Python
https://chainladder-python.readthedocs.io/en/latest/
Mozilla Public License 2.0
192 stars 71 forks source link

Medial and geometric averages #272

Open genedan opened 2 years ago

genedan commented 2 years ago

Hey guys,

Do you think it would be possible to add medial and geometric average options to the Development class? I've been working on a FASLR feature where the user can select which types of averages they want displayed on their screen. So far I've included the chainladder supported options (simple, volume, regression) and would like to add these two:

image

image

jbogaardt commented 2 years ago

This looks really slick @genedan.

These averages are reasonable requests. The only reason we don't have them now is because the Development estimator uses the weighted regression framework described by Mack. This keeps the Development fully compatible with MackChainladder for computing reserve variability.

Medial value and geometric average don't fit the framework, so it would break full compatibility. With all that said, I'm sure 95+% of usage of Development is for deterministic workflows.

We probably need to tighten up error handling on potential usage of Mack + LDF estimators that don't have variability properties anyway. All this to say - yes, we can/should do this. But bear with us as it has broader implications we will want to address in tandem.

kennethshsu commented 2 years ago

@genedan this is indeed super cool!

By the way, is medial average the same as straight average excluding high and low? This is now available. Just be careful that near the tail when there are not enough factors to drop, the drop_high and drop_low will be ignored by preserve. More info here.

import chainladder as cl
cl.Development(drop_high = 1, drop_low = 1).fit(cl.load_sample("raa")).ldf_

@jbogaardt for the geometric scenario, can we just leave all the error terms empty? I get that it will break some functionalities, but it could still be useful?

jbogaardt commented 2 years ago

Yes, we can bypass the error terms, but we should do so carefully. The MackChainladder requires std_err_ and sigma_ to be populated for each development age. To enforce this, the MackChainladder naively looks for the presence of the sigma_ property with no further validation. Suposing a user selects 'geometric' for one development age and a mack-compliant average for the others, MackChainladder will fail with poor error handling since sigma_ will be present, but invalid.