-
Notifications
You must be signed in to change notification settings - Fork 90
Description
Are you on the latest chainladder version?
- Yes, this bug occurs on the latest version.
Describe the bug in words
Discussed in #579
The BarnettZehnwirth estimator fails to convert some values of valuation to categories if given a formula that contains C(valuation) or some similar term. In particular, a PatsyError is raised: Error converting data to categorical: observation with value X does not match any of the expected levels, where X is the next valuation date after the latest diagonal converted to an ordinal.
How can the bug be reproduced?
import chainladder as cl
abc = cl.load_sample('abc')
cl.BarnettZehnwirth(formula='C(valuation)').fit(abc)
What is the expected behavior?
BarnettZehnwirth should estimate coefficients for valuations up to the latest diagonal. Future valuation categories could be dropped or have their coefficients set to zero.
Fitting data with BarnettZehnwirth also populates the resultant triangle with model expectations (and predictions) for each cell in Triangle.model_.triangle_ml_. The estimator should use valuation category coefficients for this estimation when it can.
I'm not sure how to do the above in a way that works with Patsy and fitted triangle calculations.