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.
- 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.
- 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
- 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)¶ - Description:
- Density for the Generalized Pareto distribution function
- Input parameters:
- scale, location, shape: parameters of GPD x is the data element obtained from Fitbygpdpwm function log= by default False
- 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)¶ - Description: Compute true statistics for Generalized Pareto distribution
- Input parameter:
- shape, location, scale parameters from generalized pareto distribution
- 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)¶ - Description: Generates random variates from a GPD distribution
- 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
- Result:
- list of simulate values from generalized pareto distribution
-
pwmdist.gpdpwmFit.
gpdpwmFitCheck
(data, ci=0.95, threshold=None)¶ - Description:
Checks the Fit of GPD with probability weighted moments
- 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.
- Results:
A dictionary of parameter estimates, threshold and excess.
-
pwmdist.gpdpwmFit.
pgpd
(q, location=0, scale=1, shape=1, lowertail=True)¶ - Description:
- Probability for the Generalized Pareto distribution function
- Input parameters:
- scale, location, shape: parameters of GPD lowertail = by default True
-
pwmdist.gpdpwmFit.
qgpd
(p, location=0, scale=1, shape=1, lowertail=True)¶ - Description:
- Quantiles for the Generalized Pareto distribution function
- 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)¶ - Description: Tail of Underlying Distribution
- Arguments:
- x - an object of class fGPDFIT labels - a logical flag. Should labels be printed?
- Example:
- obj= Fitbygpdpwm(data, ci, threshold) disttail(obj)
-
pwmdist.gpdplots.
empericalplt
(obj, labels=True)¶ - Description:
- Empirical Distribution Plot
- Input parameters:
- obj = Fitbygpdpwm function output labels = By default True
- Example:
- obj= Fitbygpdpwm(data, ci, threshold) empericalplt(obj)
-
pwmdist.gpdplots.
residualplot
(obj, labels=True)¶ - 1)Description:
- Quantile-Quantile Plot of GPD Residuals
- Arguments:
- obj = Fitbygpdpwm function output labels - a logical flag. checks if labels should be printed.
- Example:
- obj = Fitbygpdpwm(data, ci, threshold) residualplot(obj)
-
pwmdist.gpdplots.
tailestimategpd
(obj, labels=True)¶ - Description:
- Plots tail estimate from GPD model
- Arguments:
- obj = Fitbygpdpwm function output labels = By default True
- Example:
- obj= Fitbygpdpwm(data, ci, threshold) tailestimategpd(obj)