A new version of fanchart is available to download from pip.

Release Notes
- fanchart had a major update (in v1.0.0) as it now reads directly the quantities (mode, uncertainty, and skewness) as provided by the Bank of England and makes the appropriate transformation to obtain the parameters ($\mu, \sigma, \gamma$) to construct the forecast distributions.
- Previous versions of the package considered that the quantities provided by BoE were already transformed. However, recent communication with the BoE clarified that the last quantity, labeled as “Skewness”, was not equal to $\gamma$ but to the spread between the mean and the mode of the distribution. Thus, the latest versions of fanchart take this information and calculate $\gamma$ to produce the correct distributions. See the mathematical details below.
- In addition, fanchart 1.0.2 provided a dark theme version of the charts via the functions
fan_dark
fan_single_dark
Demo
Further Details on the Parameters Calculation
Historical observations showed that inflation outcomes were not symmetrically dispersed around a central value, with the values closer to the centre being more likely than those further away. This led to the choice of the two-piece normal distribution, which can capture asymmetry through a skewness parameter, for the forecast model. The probability density function (pdf) of the two-piece normal is defined as $$
s(x) := s\left(x; \mu,\sigma_1,\sigma_2\right) =
\begin{cases}
\dfrac{2}{\sigma_1+\sigma_2}f\left(\dfrac{x-\mu}{\sigma_1}\right), \qquad \mbox{if } x < \mu, \\
\dfrac{2}{\sigma_1+\sigma_2}f\left(\dfrac{x-\mu}{\sigma_2}\right), \qquad \mbox{if } x \geq \mu, \\
\end{cases}
$$ where $f: \mathbb{R} \mapsto \mathbb{R}_{+}$ is the pdf of the standard normal distribution. However, the Bank of England uses the following re-parametrisation:$$
\sigma_1 = \dfrac{\sigma}{\sqrt{1-\gamma}} ; \qquad
\sigma_2 = \dfrac{\sigma}{\sqrt{1+\gamma}},
$$ where $\sigma >0$ and $\gamma \in (-1, 1)$. Thus, the pdf of the two-piece normal can be written as$$
s(x) := s\left(x; \mu,\sigma,\gamma\right) =
\begin{cases}
\dfrac{A}{\sqrt{2\pi}\sigma} \exp \left\{ -\dfrac{1-\gamma}{2\sigma^2} \left[(x-\mu)^2\right] \right\}, \qquad \mbox{if } x < \mu, \\
\dfrac{A}{\sqrt{2\pi}\sigma} \exp \left\{ -\dfrac{1+\gamma}{2\sigma^2} \left[(x-\mu)^2\right] \right\}, \qquad \mbox{if } x \geq \mu, \\
\end{cases}
$$ where $A = \dfrac{2}{\frac{1}{\sqrt{1-\gamma}}+\frac{1}{\sqrt{1+\gamma}}}$.
So, in order to derive the forecast distribution for each quarter ahead, three parameters need to be estimated:
- $\mu$ : a measure of the central tendency for inflation
- $\sigma$ : a view on the degree of uncertainty
- $\gamma$ : a view on the balance of the risks, to get a measure of the skew.
The BoE publishes three quantities as part of its quarterly report, labeled as:
- Mode, this corresponds to $\mu$
- Uncertainty, this corresponds to $\sigma$
- Skewness, this is the difference between the mean and the mode of the distribution, i.e., $ E[X] – \mu$.
Note that the value of $\gamma$ can be calculated as a function of this last quantity and $\sigma$ as follows:
$$\gamma^2 = 1 – 4 \left( \frac{ \sqrt{ 1 +\pi s^2} -1}{\pi s^2} \right)^2,$$
where
$$s = \dfrac{E[X] -\mu}{\sigma},$$
and $\gamma$ takes the sign of $s$. This transformation is now implemented in the fanchart package. So we can simply pass the quantities provide by the BoE to reproduce the fancharts.
One thought on “fanchart 1.0.2”