Coder Social home page Coder Social logo

fanchart's Introduction

fanchart

PyPI version fury.io Downloads

PyPI license example workflow Documentation Status

Overview

The fanchart library provides functionality to create fan charts in Python.

The term fan chart was coined by the Bank of England in 1996. Since then, the BoE has used these charts to illustrate its forecasts for inflation.

The BoE introduced the fan charts aiming to communicate a more accurate representation of their forecast for medium term inflation. In particular, the charts have two key objectives:

  • To convey the uncertainty in their forecasts. This is, to focus attention on the forecast distribution, rather than only on small changes to the central projection.
  • To promote discussion of the risks to the economic outlook, and thus contribute to a wider debate about economic policy. Fan charts help to make it clear that monetary policy is about making decisions instead of knowing the exact rate of inflation in two years time.

For more details on the history of fan charts visit Fan Charts

Installation

Fanchart is available on pypi and can be installed as follows.

pip install fanchart

Dependencies

Fanchart relies heavily on

Compatibility

Fanchart is tested on Python versions 3.8, 3.9, and 3.10

Getting Started

โ— ๐Ÿ“ Install the latest version of fanchart before starting.

This library provides two main functions fan and fan_single. In order to be able to make our first fan charts with these functions, we need to load some data via the functions.

  • load_boe_history() which loads the historical data for inflation (CPI)
  • load_boe_parameters() which loads the parameters for the quarterly projections
from fanchart import load_boe_history, load_boe_parameters

history = load_boe_history()
parameters = load_boe_parameters()

After this, we are ready to use our main functions.

  • The fan function illustrates the distribution of all the forecasts available; and it has the option to display the historical values for reference.
    from fanchart import fan

    probs = [0.05, 0.20, 0.35, 0.65,0.80,  0.95]
    fan(pars=parameters, probs=probs, historic=history[history.Date >= '2018'])

  • The fan_single function illustrates the pdf/cdf of one forecast distribution
    from fanchart import fan_single

    probs = [0.05, 0.20, 0.35, 0.65,0.80,  0.95]
    fan_single(loc=9.53, sigma=1.68, gamma=1.0, probs=probs, kind='pdf')

    from fanchart import fan_single

    probs = [0.05, 0.20, 0.35, 0.65,0.80,  0.95]
    fan_single(loc=9.53, sigma=1.68, gamma=1.0, probs=probs, kind='cdf')

Thanks for Visiting! โœจ

Connect with me via:

โญ๏ธ If you like this projet, please give it a star! โญ๏ธ

fanchart's People

Contributors

quantgirluk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fanchart's Issues

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.