DoubleParetoLogNormal Distribution is now a ResourceFunction

The NormalLaplaceDistribution is also available as a resource function. The functions were revised so that they work independently of each other.
In[]:=
DPLN=ResourceFunction["DoubleParetoLogNormalDistribution"]
Out[]=
[◼]
DoubleParetoLogNormalDistribution
In[]:=
NL=ResourceFunction["NormalLaplaceDistribution"]
Out[]=
[◼]
NormalLaplaceDistribution
Here is an example of using the DoubleParetoLogNormalDistribution to give a better tail fit to data of a volatility measure than does the generalized extreme value distribution. See A simple intraday volatility measure. Quiet is used because the range of values gets outside machine numbers for a compiled function which reverts to non-compiled version.
In[]:=
ts=FinancialData["SPY","OHLC",{2008}];​​lnhilo=Log[#2/#3]&@@@Normal[QuantityMagnitude[ts]["Values"]];​​dplnD=Quiet@EstimatedDistributionlnhilo,
[◼]
DoubleParetoLogNormalDistribution
[α,β,μ,σ]
Out[]=
[◼]
DoubleParetoLogNormalDistribution
[2.53344,63.1507,-4.96026,0.527384]
The tail fit misses only the last three points of the data, which are not likely accurately represented in the EmpiricalDistribution, given the size of the sample. On the LogLog plot the right tail plotted as a survival function becomes linear.
In[]:=
empD=EmpiricalDistribution[lnhilo];​​LogLogPlot[{1-CDF[dplnD,x],1-CDF[empD,x]},{x,0.005,Max[Abs[lnhilo]]},GridLines->Automatic,PerformanceGoal->"Speed",PlotLabel->"Tail Fit Log[hi/lo]"]
General
:7.28871×
-152
10
×5.0894×
-234
10
is too small to represent as a normalized machine number; precision may be lost.
Out[]=
Goodness of fit testing.
In[]:=
HT=DistributionFitTest[lnhilo,dplnD,"HypothesisTestData"];​​HT["TestDataTable",All]
Out[]=
Statistic
P-Value
Anderson-Darling
0.641106
0.60999
Cramér-von Mises
0.0975762
0.596888
Kolmogorov-Smirnov
0.0111657
0.668791
Kuiper
0.0199965
0.375115
Pearson
2
χ
68.9203
0.115111
Watson
2
U
0.0959481
0.299845
The log of the data has the shape of a NormalLaplaceDistribution; the fitting is easier using the Log[data], so it is the NormalLaplaceDistribution which is used for fitting. Both ResourceFunctions are written so that they are independent, but they use the same code.
In[]:=
nlfit=Quiet@EstimatedDistribution[Log[lnhilo],NL[α,β,μ,σ]]​​dplnD
Out[]=
[◼]
NormalLaplaceDistribution
[2.53344,63.1507,-4.96026,0.527384]
Out[]=
[◼]
DoubleParetoLogNormalDistribution
[2.53344,63.1507,-4.96026,0.527384]
The functions are designed so the parameters look the same but the functions are very different, similar to the Normal and LogNormal distributions.
In[]:=
Plot[PDF[nlfit,x],{x,-8,1},PlotRange->All,PlotLabel->"NormalLaplace"]​​Plot[PDF[dplnD,x],{x,0,0.1},PlotRange->All,PlotLabel->"DoubleParetoLogNormal"]
Out[]=
General
:
65.6841
2.04286×
-6
10
is too small to represent as a normalized machine number; precision may be lost.
Out[]=