pwmdist package

gpdpwmFit module

The ‘gpdpwmFit’ module facilitates fitting a timeseries data with Generalized pareto distribution using probability weighted moments estimation method for parameter estimates. It also provide key distribution statistics, Risk measures and GPD simulated values.

pwmdist.gpdpwmFit.Fitbygpdpwm(data, ci=0.95, threshold=None)

1) Description: The function fits Generalized pareto distiribution to the passed dataset; a timeseries object using probability weighted moments method.

  1. Input Parameters:
    data: timeseries dataframe. ci: confidence interval threshold: A float, A threshold number obtained from Peak over threshold method If the threshold value is passed than the manual threshold value is used else the quantile at a given confidence interval is used to calculate the threshold.
  2. Results:
    The function returns a dicitionary, which has data, list of residuals, probability, shape parameter, scale parameter, list of exceedances (case where data[i]>threshold), threshold value, excess(case in exceedances subtracted from threshold.) This result dictionary can be used in the plot functions
  3. Example:
    the example of the “data” parameter is as follows: Date log(return) 25-12-2020 0.11098978 26-12-2020 0.14787224
pwmdist.gpdpwmFit.depd(x, location=0, scale=1, shape=0, log=False)
  1. Description:
    Density for the Generalized Pareto distribution function
  2. Input parameters:
    scale, location, shape: parameters of GPD x is the data element obtained from Fitbygpdpwm function log= by default False
  3. Example:
    fit=Fitbygpdpwm(dataframe, ci=0.95, threshold=None) depd(fit[‘data’], location, scale=fit[‘scale’],shape= fit[‘shape’], log=False)
pwmdist.gpdpwmFit.gpdMoments(shape=1, location=0, scale=1)
  1. Description: Compute true statistics for Generalized Pareto distribution
  2. Input parameter:
    shape, location, scale parameters from generalized pareto distribution
  3. Value:
Returns true mean of Generalized Pareto distribution for xi < 1 else NaN Returns true variance of Generalized Pareto distribution for xi < 1 else NaN
pwmdist.gpdpwmFit.gpdSimulation(shape=0.25, location=0, scale=1, n=1000, seed=None)
  1. Description: Generates random variates from a GPD distribution
  2. Input parameters:
    shape, location, scale = the parameter estimates that can be either manually input or taken from Fitbygpdpwm function n = number of simulated observations seed = by default None
  3. Result:
    list of simulate values from generalized pareto distribution
pwmdist.gpdpwmFit.gpdpwmFitCheck(data, ci=0.95, threshold=None)
  1. Description:

    Checks the Fit of GPD with probability weighted moments

  2. Input Parameters:

    data= timeseries dataframe

    ci= confidence interval

    threhsold=A float, A threshold number obtained from Peak over threshold method If the threshold value is passed than the manual threshold value is used else the quantile at a given confidence interval is used to calculate the threshold.

  3. Results:

    A dictionary of parameter estimates, threshold and excess.

pwmdist.gpdpwmFit.pgpd(q, location=0, scale=1, shape=1, lowertail=True)
  1. Description:
    Probability for the Generalized Pareto distribution function
  2. Input parameters:
    scale, location, shape: parameters of GPD lowertail = by default True
pwmdist.gpdpwmFit.qgpd(p, location=0, scale=1, shape=1, lowertail=True)
  1. Description:
    Quantiles for the Generalized Pareto distribution function
  2. Input parameters:
    scale, location, shape: parameters of GPD lowertail = by default True

gpdplots module

The ‘gpdplots’ module facilitates the essential visualization of empirical distiribution plot, tail of the underlying distribution , tail estimates from GPD model (from ‘Fitbygpdpwm’ method) and residual plots.

pwmdist.gpdplots.disttail(obj, labels=True)
  1. Description: Tail of Underlying Distribution
  2. Arguments:
    x - an object of class fGPDFIT labels - a logical flag. Should labels be printed?
  3. Example:
    obj= Fitbygpdpwm(data, ci, threshold) disttail(obj)
pwmdist.gpdplots.empericalplt(obj, labels=True)
  1. Description:
    Empirical Distribution Plot
  2. Input parameters:
    obj = Fitbygpdpwm function output labels = By default True
  3. Example:
    obj= Fitbygpdpwm(data, ci, threshold) empericalplt(obj)
pwmdist.gpdplots.residualplot(obj, labels=True)
1)Description:
Quantile-Quantile Plot of GPD Residuals
  1. Arguments:
    obj = Fitbygpdpwm function output labels - a logical flag. checks if labels should be printed.
  2. Example:
    obj = Fitbygpdpwm(data, ci, threshold) residualplot(obj)
pwmdist.gpdplots.tailestimategpd(obj, labels=True)
  1. Description:
    Plots tail estimate from GPD model
  2. Arguments:
    obj = Fitbygpdpwm function output labels = By default True
  3. Example:
    obj= Fitbygpdpwm(data, ci, threshold) tailestimategpd(obj)