-
Notifications
You must be signed in to change notification settings - Fork 91
Description
Are you on the latest chainladder version?
- Yes, this bug occurs on the latest version.
Describe the bug in words
The standardized residual triangle computed here is missing the last value of origin year 1981. I think this is a floating point error caused by residual computation subtracting two numbers that are very close. This can happen at either end of the latest valuation of the triangle. Edit: This doesn't always happen when subtracting two very close numbers, and I'm not sure what causes the subtraction issue exactly.
I noticed similar behavior in BarnettZehnwirth's computatino of standardized residuals, but didn't note down the steps to replicate it. Replacing regular subtraction operations with np.subtract seems to rectify this problem.
Subtraction is a pretty common operation and I'm not sure if/how commonly this creates a problem elsewhere. I suspect it does, so I'll amend this issue if someone finds something else.
How can the bug be reproduced?
From the development section of the user guide
import chainladder as cl
raa = cl.load_sample('raa')
model = cl.Development().fit(raa)
model.std_residuals_
setting a breakpoint within development.py where resid is computed makes the problem more obvious
What is the expected behavior?
That NaN should be 0.0 instead