-
Notifications
You must be signed in to change notification settings - Fork 73
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
BUG in ChainLadder grain OYDQ #480
Comments
Thanks for finding this, it is definitely an issue. |
@jbogaardt Do you have a rough idea where this bug origins? |
I've been trying to use this to get more understanding of how Chainladder package work. Of what I can see it seem like the issue is that the function call latest_diagonal.val_to_dev() don't get the same dimensions as the original triangle, but starts from period 12.
This when _align_cdf is called it then uses this shape, and gets the fifth element for 2000 which is 1.6 and 1 for 2001 which is 8. The easy fix seems to use incr_to_cum() instead of latest_diagonal when using incremental. That is change get_ultimate to: def _get_ultimate(self, X, sample_weight=None):
""" Private method that uses CDFs to obtain an ultimate vector """
if X.is_cumulative == False:
ld = X.incr_to_cum().latest_diagonal #ld = X.sum('development')
ultimate = X.incr_to_cum().copy() #ultimate = ld.val_to_dev()
else:
ld = X.latest_diagonal
ultimate = X.copy()
cdf = self._align_cdf(ultimate, sample_weight)
ultimate = ld * cdf
return self._set_ult_attr(ultimate) This gives same output as creating the cumulative triangle first, and tests are passing. But I'm not sure the side effects of this change. And if the issue actually is val_to_dev, than this maybe is just hiding something that should have been taken care of. I've tried to take a deeper look at val_to_dev, but not skilled enough yet. @jbogaardt - Any idea how to fix this in an efficient and simple way? 😄 |
FYI - same error occurs when using Benktander: dev = cl.Development(average="volume").fit_transform(tr)
cl.Benktander(apriori=1, n_iters=10000).fit(dev, sample_weight =dev.latest_diagonal).full_triangle_ Seems like changing align_cdf_ passes all tests, by using something with original form, for instance Just another thought - may it be better to aggregate everything to cumulative at initiation? Instead of testing in the different models? Then one probably only have to do conversion back when using IO methods like to_frame/to_json/to_pickle? |
results in
Observe the predicted 7 in dev period 15, 28, 21 and 24 for OY 2001. This is pretty odd!!!
The triangle without estimation reads
When the grain is changed to same O and D, it seems to work fine. But with different origin and development steps not.
BTW, there is an additional warning
The text was updated successfully, but these errors were encountered: