Git Product home page Git Product logo

py_vsk's Introduction

PY_VSK

- A Collection of Python Functions for Vasicek Distribution

Introduction

In the context of statistics, the Vasicek distribution is a continuous distribution governing the open interval between 0 and 1 with two parameters, namely Rho and P, which is similar to the Beta and Kumaraswamy distributions.

The Vasicek distribution has often been used to describe the portfolio credit loss in the development of Economic Capital models. The py_vsk package is a collection of miscellaneous python functions related to the Vasicek distribution with the intent to make the lives of risk modelers easier.

Core Functions

py_vsk
  |-- vsk_mle()   : Estimates Vasicek parameters by using MLE.
  |-- vsk_imm()   : Estimates Vasicek parameters by using indirect moment matching.
  |-- vsk_dmm()   : Estimates Vasicek parameters by using direct moment matching.
  |-- vsk_qbe()   : Estimates Vasicek parameters by using quantile-based estimator.
  |-- vsk_Rho()   : Estimates the Rho parameter by assuming P known and varying.
  |-- vsk_pdf()   : Calculates the probability density function of Vasicek.
  |-- vsk_cdf()   : Calculates the probability cumulative function of Vasicek.
  |-- vsk_ppf()   : Calculates the percentile point function (CDF inverse) of Vasicek.
  |-- vsk_rvs()   : Generates random numbers following the Vasicek distribution.
  |-- get_Rho()   : Solves for the Rho parameter such that vsk_cdf(x, Rho, P) = Alpha.
  |-- gof_ks()    : Performs the Kolmogorov-Smirnov GoF test for the Vasicek distribution.
  `-- gof_chisq() : Performs the Chi-Square GoF test for the Vasicek distribution.

Example

While future default rates cannot be predicted with certainty, the probability of default rates can be assessed based on the appropriate statistical distribution.

Below is the list of delinquent rates for 100 largest banks in the last 20 years (https://www.federalreserve.gov/releases/chargeoff/deltop100nsa.htm).

df = [0.0171, 0.0214, 0.0275, 0.0317, 0.0400, 0.0533, 0.0692, 0.0901, 0.0984, 0.1051, 
      0.1117, 0.0684, 0.0317, 0.0190, 0.0158, 0.0139, 0.0179, 0.0200, 0.0241, 0.0264]

Based on the above, we can estimate parameters of the corresponding Vasicek distribution. While the P parameter shows the long-term average of delinquent rates, the Rho parameter describes the degree of association with systematic risk factors.

import py_vsk
py_vsk.vsk_mle(df)
# {'Rho': 0.0939762321, 'P': 0.0446574471}

The delinquent rate reached the highest of 11.17% in 2009 and is equivalent to ~96%ile in the corresponding Vasicek distribution, suggesting that the 2009 downturn is an 1-in-25 event.

py_vsk.vsk_cdf([max(df)], 0.0939762321, 0.0446574471)
# [{'x': 0.1117, 'cdf': 0.9609532701414676}]

In addition, the result below shows that there is an 1% chance that the delinquent rate could be as high as 15%.

py_vsk.vsk_ppf([0.99], 0.0939762321, 0.0446574471)
# [{'Alpha': 0.99, 'ppf': 0.15016266823403973}]

Reference

Tasche, Dirk. (2008). The Vasicek Distribution.

py_vsk's People

Contributors

statcompute avatar

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.