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

#438 bug #440

Closed kennethshsu closed 1 year ago

kennethshsu commented 1 year ago

Addressing #438

kennethshsu commented 1 year ago

@jbogaardt can you help resolve some of the unit tests regarding installation?

Also, I don't think my solution will work, it will break when the valuations are less granular than annual. Looking deeper.

jbogaardt commented 1 year ago

it looks like pandas no longer supports TimeDelta of Month as it is ambiguous. It can be anywhere between 28 and 31 days.

Numpy treats a month as 30 days regardless, and this is causing conversion from days to months to fail:

imprt numpy as np
np.timedelta64(1, 'M').astype('timedelta64[D]')

I've played with using (365/12) as the monthly value and it seems to restore the correct ages.

kennethshsu commented 1 year ago

Right, I think the only way to get around it is to actually calculate the development age using year and month manually. Using anything from pandas or numpy will force the calculation to be too accurate, and we'll then need to be forced to round and result in possible error.