chainladder-python icon indicating copy to clipboard operation
chainladder-python copied to clipboard

Latest n diagonal in heatmap()

Open kennethshsu opened this issue 2 years ago • 8 comments

Is there an easy way to heatmap() only the latest n diagonal? I supposed we can add in another parameter, I propose last_n_diagonal, default to None?

kennethshsu avatar Mar 16 '22 18:03 kennethshsu

Yes, you can use the Development estimator to omit any link ratios and those should propagate to the heatmap.

import chainladder as cl
cl.Development(n_periods=3).fit_transform(cl.load_sample('raa')).link_ratio.heatmap()

jbogaardt avatar Mar 16 '22 18:03 jbogaardt

Ahh, similar solution to what I came up with.

raa = cl.load_sample("raa")
cl.Development().fit_transform(raa[raa.valuation.year >= raa.valuation_date.year-3]).link_ratio.heatmap()

I think I am getting better at this. Only problem is now we can't see the older link ratios.😅

kennethshsu avatar Mar 16 '22 18:03 kennethshsu

Cool. By your approach you don't even need the Development estimator:

raa = cl.load_sample('raa')
raa.link_ratio[raa.link_ratio.valuation.year >= raa.valuation_date.year-3].heatmap()

jbogaardt avatar Mar 16 '22 18:03 jbogaardt

Yes, even better!

kennethshsu avatar Mar 16 '22 18:03 kennethshsu

Should this be reclassifed discussion forum Q&A?

jbogaardt avatar Mar 19 '22 15:03 jbogaardt

Yes, unless you think it's useful to add an argument to only heatmap the last n diagonals? It's a bit better as we can see the older diagonals that are not heat-mapped. But it will mean that it's another piece of code that we have to maintain. What do you think?

kennethshsu avatar Mar 19 '22 20:03 kennethshsu

I fear n_diagonals will be short lived. Eventually someone will want the same but with drop_hi and drop_low. I dont want to create more args for those use cases.

Maybe it's better to create a Boolean arg in heatmap that allows the dropped link ratios from the Development estimator to be visible or not.

jbogaardt avatar Mar 19 '22 21:03 jbogaardt

That's actually a great idea. I like that.

With this we should be able to see if the remaining LDFs have any patterns.

kennethshsu avatar Mar 19 '22 21:03 kennethshsu