Skip to content

BarnettZehnwirth does not support categorical valuation predictors #623

@danielfong-act

Description

@danielfong-act

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.

Metadata

Metadata

Labels

Effort > Brief 🐇Small tasks expected to take a few hours up to a couple of days.Great First Contribution! 🌱Beginner friendly tickets with narrow scope and huge impact. Perfect to join our community!Impact > Minor 🔷Small, backward compatible change. Treat like a patch release (e.g., 0.5.8 → 0.5.9).

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions