quantgirluk / fanchart

📦 Python library to create Fan Charts as introduced by the Bank of England in 1996
MIT License
14 stars 2 forks source link

Breaks if Skewness >= 1 as in BoE's latest forecast #1

Closed brimoran closed 2 years ago

brimoran commented 2 years ago

I love what you've done here.

I wanted to see if I could reproduce the latest BoE fanchart (August 2022) but I am encountering the attached error message.

I have played around a bit with the data to try to see what is causing the issue and I think it occurs when Skewness >= 1 as it is in the latest BoE projections for two periods

Screenshot 2022-08-12 at 17 25 16
quantgirluk commented 2 years ago

Thanks for finding this issue. Investigation in progress.

brimoran commented 2 years ago

Great :)

quantgirluk commented 2 years ago

After investigating this issue, I have found that the package behaviour is consistent with the assumptions of the distribution forecasts as twopiece normals. That is, the skewness parameter should be in (-1, 1). So, the only change that I plan to make to the package is to raise an appropriate warning when parameters out of range are provided. I wrote a brief explanation about this on my blog. Thanks again for highlighting this to me.

brimoran commented 2 years ago

Interesting! Great blog post. Thanks for looking into this and for publishing your insight into what the out of range skewness implies.

quantgirluk commented 2 years ago

After some communication with BoE, they confirmed that what is published in their recent spreadsheet as Skewness is not the actual $\gamma$ parameter. Instead, they publish Skewness = difference between the mean and the median of the distribution. This quantity indeed can be outside the interval (-1, 1). So, what I did was to change my package twopiece (release 1.3.1) to accept this quantity and then calculate the parameter $\gamma$. This will in turn solve the issue with the fancharts. Besides, I updated fanchart (release 1.0.0) to require twopiece>=1.3.1. So, you can just update fanchart and the correct twopiece will be installed. Once again, thanks for highlighting this issue! It was very helpful.