# Fitting tail of distribution to Generalized Pareto Distribution

Hello, I have a problem in Mathematica and I don’t know if you could help me. I’m trying to compare the “performance” of a Laplace distribution and a Generalized Pareto Distribution (GPD) for the tail of a distribution of returns. But, as you can see in the image, when I truncate the histogram to fit the tail to a GPD and try to compare them in the histogram, the PDF histogram has changed its probabilities (like changing its scale). How can I plot them so the GPD represents the probability of the tail of the original histogram?

I would like to have something similar to this second image but in a PDF histogram because I want to have the half Laplace and the GPD in the same "scale". Sorry, Im new here. Here is the code:

q = Quantile[wReturns, 0.5]

tail = Cases[wReturns, x_ /; x >= q];

ldist = EstimatedDistribution[wReturns, LaplaceDistribution[a, b]]

pdist = EstimatedDistribution[tail, ParetoPickandsDistribution[a, b, c]]

Show[Histogram[{tail, wReturns}, Automatic, PDF, PlotRange -> All], Plot[{PDF[ldist, x], PDF[pdist, x]}, {x, Min[tail], Max[tail]}, PlotRange -> All]]

WReturns is a vector of Returns and GPD is the Generalized Pareto Distribution (or Pareto Picklands).

Sorry if the question is not clear. I will edit again if necessary.

I've found this picture. I would like to have a plot like this (or at least half of this plot):

I do not know how to do it with the truncated Laplace distribution.

• We cannot reproduce your figures without representative data and the definitions that you used for ldist and pdist. While I assume that GPD is "generalized Pareto distribution", you should not use acronyms without spelling them out the first time they are used. Please edit your question. Jul 7, 2019 at 17:27
• What's a GPD? The distribution of a truncated random variable is not comparable to "half" of a distribution. Please show how your data was processed and display that as code that one can copy-and-paste rather than as an image.
– JimB
Jul 7, 2019 at 17:27
• q = Quantile[wReturns, 0.5] tail = Cases[wReturns, x_ /; x >= q]; ldist = EstimatedDistribution[wReturns, LaplaceDistribution[a, b]] pdist = EstimatedDistribution[tail, ParetoPickandsDistribution[a, b, c]] Show[Histogram[{tail, wReturns}, Automatic, PDF, PlotRange -> All], Plot[{PDF[ldist, x], PDF[pdist, x]}, {x, Min[tail], Max[tail]}, PlotRange -> All]] Jul 7, 2019 at 17:30
– JimB
Jul 7, 2019 at 17:31
• Okey, sorry. Now I have edited the question. Jul 7, 2019 at 17:39

If you are comparing fits, then you need to compare the estimated distributions rather than the histograms. (In this case I think that visually comparing histograms doesn't make any sense because the exact same data is used in the tails for both candidate distributions.) Also, I think you need to compare truncated distributions or non-truncated distributions but not mix the two.

Here is one way to compare truncated distributions. This approach, however, only gives appropriate estimates of the precision of the estimators when the truncation point is known as opposed to estimating a potential truncation point. (If the truncation point is the mode of the Laplace distribution, then probably a bootstrap approach is necessary to estimate levels of precision.)

(* Generate sample data from a Laplace distribution *)
SeedRandom[12345];
data = RandomVariate[LaplaceDistribution[0, 1], 1000];

(* Set the known truncation parameter *)
μ = 0;

(* Get a random sample from a truncated Laplace *)
truncatedData = Select[data, # > μ &];

(* Fit a truncated Laplace distribution with known location parameter *)
truncatedLaplace = TruncatedDistribution[{μ, ∞}, LaplaceDistribution[μ, β]];
mleTruncatedLaplace = FindDistributionParameters[truncatedData, truncatedLaplace]
(* {β -> 0.9174614004579854} *)

(* Use the same data to estimate a ParetoPickands distribution *)
mlePareto = FindDistributionParameters[truncatedData, ParetoPickandsDistribution[μ, σ, ξ]]
(* {σ -> 0.8815521215127279,ξ -> 0.03923149023223031} *)

(* Plot results *)
Plot[{PDF[truncatedLaplace /. mleTruncatedLaplace, x],
PDF[ParetoPickandsDistribution[μ, σ, ξ] /. mlePareto, x]}, {x, -5, 5}, PlotRange -> All]


One can't see much of a difference in the two curves. (Your data will, of course, have a different result.

(* Compare results using AIC *)
aicTruncatedLaplace = 2*1 - 2 LogLikelihood[truncatedLaplace /. mleTruncatedLaplace, truncatedData]
(* 926.8214929435766 *)
aicParetoPickands = 2*2 - 2 LogLikelihood[ParetoPickandsDistribution[μ, σ, ξ] /. mlePareto, truncatedData]
(* 928.1182631364919 *)
aicDifference = aicParetoPickands - aicTruncatedLaplace
(* 1.2967701929153463 *)
`

The truncated Laplace fit has a slightly smaller AIC value which suggests maybe a better fit (but given that the difference is less than 2 I wouldn't take such a difference too seriously).

An alternative is to compare the fits of the non-truncated distributions. Here one would estimate the truncation point (assuming that would be the mode of the non-truncated distribution) and have a Laplace probability density to the left of that truncation point and a ParetoPickands to the right.

• Thank you, this is exactly what I needed. Do you think the mode is the adequate truncantion point? Because the only justification that I have is that it fits best when I select that point. Jul 9, 2019 at 14:13
• Here's my frequently given sermon: The necessary information to make a decision is not an intrinsic property of the data. You as the subject matter expert need to decide on what the consequences are for not having an adequate fit and where the fit needs to be accurate. For example, maybe it's at the 95% percentile and higher that's most important rather than at the median (which is the same as the mode in this case). (And by "it fits best" I assume you mean a "visual inspection" so I wouldn't call that a very objective or repeatable-by-others justification.)
– JimB
Jul 9, 2019 at 15:15