| Title: | Estimators and Plots for Gamma and Pareto Tail Detection |
|---|---|
| Description: | Estimators for two functionals used to detect Gamma, Pareto or Lognormal distributions, as well as distributions exhibiting similar tail behavior, as introduced by Iwashita and Klar (2023) <doi:10.1111/stan.12316> and Klar (2024) <doi:10.1080/00031305.2024.2413081>. One of these functionals, g, originally proposed by Asmussen and Lehtomaa (2017) <doi:10.3390/risks5010010>, distinguishes between log-convex and log-concave tail behavior. Furthermore the characterization of the lognormal distribution is based on the work of Mosimann (1970) <doi:10.2307/2284599>. The package also includes methods for visualizing these estimators and their associated confidence intervals across various threshold values. |
| Authors: | Bernhard Klar [aut, cre], Lucas Iglesias [aut] |
| Maintainer: | Bernhard Klar <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-06-05 08:14:15 UTC |
| Source: | https://github.com/cran/tailplots |
This function computes the estimate of and the associated confidence interval for as well as , the corresponding shape parameter under the assumption of a gamma model, according to Iwashita and Klar (2024). Three methods are implemented to compute the confidence intervals: a method based on the unbiased variance estimators of the underlying U-statistics, and two resampling methods (jackknife and bootstrap).
gamma_tail( x, d, confint = FALSE, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95 )gamma_tail( x, d, confint = FALSE, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95 )
x |
a vector containing the sample data. |
d |
the threshold for the computation of g. |
confint |
a boolean value indicating whether a confidence interval should be computed. |
method |
the method used for computing the confidence intervals (options include unbiased variance estimator, jackknife, and bootstrap). |
R |
the number of the bootstrap replicates. |
conf.level |
the confidence level for the interval. |
The function introduced by Asmussen and Lehtomaa (2017) is used to distinguish between
log-concave and log-convex tail behavior. It is defined as:
where are independent and identically distributed (i.i.d.) positive random variables.
For gamma distributions, takes a constant value, making it a useful tool for detecting gamma-tailed distributions.
This function estimates using U-statistics. The estimator is given by:
where
Confidence intervals for , based on the following variance estimation methods, are also provided:
Unbiased Variance Estimator
Bootstrap Resampling
Jackknife Resampling
The confidence interval for
is given by:
Here,
is the
appropriate quantile of the standard normal distribution and is an estimator of the standard deviation based on one of the methods above.
A matrix containing:
threshold |
The value of the threshold d. |
g.estimate |
Estimate of g. |
g.ci1 |
The lower bound of the confidence interval for g (if |
g.ci2 |
The upper bound of the confidence interval for g (if |
alpha |
Estimate of the shape parameter under a gamma model. |
alpha.ci1 |
The lower bound of the confidence interval for alpha (if |
alpha.ci2 |
The upper bound of the confidence interval for alpha (if |
Iwashita, T. & Klar, B. (2024). A gamma tail statistic and its asymptotics. Statistica Neerlandica 78:2, 264-280. doi:10.1111/stan.12316
Asmussen, S. & Lehtomaa, J. (2017). Distinguishing Log-Concavity from Heavy Tails. Risks 2017, 5, 10. doi:10.3390/risks5010010
x <- rgamma(100, shape = 2, scale = 1) gamma_tail(x, d = 2, confint = FALSE, method = "unbiased", R = 1000)x <- rgamma(100, shape = 2, scale = 1) gamma_tail(x, d = 2, confint = FALSE, method = "unbiased", R = 1000)
This function produces a tail plot for the estimate over a range of thresholds for a given sample, including confidence intervals computed by one of three methods (unbiased, bootstrap or jackknife). The function also allows a choice between original and log scale.
gamma_tailplot( x, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95, ci.points = 101, xscale = "o" )gamma_tailplot( x, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95, ci.points = 101, xscale = "o" )
x |
a vector containing the sample data. |
method |
the method used for computing the confidence intervals (options include unbiased variance estimator, jackknife, and bootstrap). |
R |
the number of the bootstrap replicates. |
conf.level |
the confidence level for the interval. |
ci.points |
the number of thresholds used in the calculation of the confidence intervals. |
xscale |
the scale of the x-axis (options include "o" = original, "l" = log scale, "b" = both). |
For more details about the estimator and the computation of the confidence intervals see gamma_tail.
A plot showing the estimated versus threshold , optionally on a logarithmic x-axis and including confidence intervals.
Iwashita, T. & Klar, B. (2024). A gamma tail statistic and its asymptotics. Statistica Neerlandica 78:2, 264-280. doi:10.1111/stan.12316
x <- rgamma(2e2, 0.5, 0.2) gamma_tailplot(x, method="unbiased", xscale="o")x <- rgamma(2e2, 0.5, 0.2) gamma_tailplot(x, method="unbiased", xscale="o")
This function computes the estimate of and the associated confidence interval for as well as the standard deviation sigma on the log-scale of the lognormal distribution. Three methods are implemented to compute the confidence intervals: a method based on the unbiased variance estimators of the underlying U-statistics and two resampling methods (jackknife and bootstrap).
lnorm_tail( x, u, confint = FALSE, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95 )lnorm_tail( x, u, confint = FALSE, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95 )
x |
a vector containing the sample data. |
u |
the threshold for the computation of s. |
confint |
a boolean value indicating whether the confidence interval should be computed. |
method |
the method used for computing the confidence intervals (options include unbiased variance estimator, jackknife, and bootstrap). |
R |
the number of the bootstrap replicates. |
conf.level |
the confidence level for the interval. |
The function , defined by
where are independent and identically distributed (i.i.d.) positive random variables, takes a constant value if and only if follows a lognormal distribution.
Thus, can be used to detect distributions with lognormal tails. The characterization of the lognormal distribution is based on the work of Mosimann (1970).
This function estimates using U-statistics, similarly as in Iwashita and Klar (2024).
A matrix containing:
threshold |
The value of the threshold u. |
s.estimate |
Estimate of the tail functional s. |
s.ci1 |
The lower bound of the confidence interval for s (if |
s.ci2 |
The upper bound of the confidence interval for s (if |
sigma |
Estimate of the scale parameter under a lognormal model. |
sigma.ci1 |
The lower bound of the confidence interval for sigma (if |
sigma.ci2 |
The upper bound of the confidence interval for sigma (if |
Mosimann, J. E. (1970). Size allometry: size and shape variables with characterizations of the lognormal and generalized gamma distributions. Journal of the American Statistical Association, 65(330):930–945. doi:10.2307/2284599
Iwashita, T. & Klar, B. (2024). A gamma tail statistic and its asymptotics. Statistica Neerlandica 78:2, 264-280. doi:10.1111/stan.12316
x = rlnorm(1e3, 2, 2) u = round( quantile(x, 0.98) ) lnorm_tail(x, u, confint = FALSE)x = rlnorm(1e3, 2, 2) u = round( quantile(x, 0.98) ) lnorm_tail(x, u, confint = FALSE)
This function produces a tail plot for the estimate over a range of thresholds for a given sample, including confidence intervals computed by one of three methods (unbiased, bootstrap or jackknife). The function also allows a choice between original and log scale.
lnorm_tailplot( x, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95, ci.points = 101, xscale = "o" )lnorm_tailplot( x, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95, ci.points = 101, xscale = "o" )
x |
a vector containing the sample data. |
method |
the method used for computing the confidence intervals (options include unbiased variance estimator, jackknife, and bootstrap). |
R |
the number of the bootstrap replicates. |
conf.level |
the confidence level for the interval. |
ci.points |
the number of thresholds used in the calculation of the confidence intervals. |
xscale |
the scale of the x-axis (options include "o" = original, "l" = log scale, "b" = both). |
A plot showing the estimated versus threshold , optionally on a logarithmic x-axis and including confidence intervals. Note that on the right side of the plot, one can observe the corresponding sigma values, which indicate the the standard deviation on the log-scale of the lognormal distribution associated with the estimated s-values.
Mosimann, J. E. (1970). Size allometry: size and shape variables with characterizations of the lognormal and generalized gamma distributions. Journal of the American Statistical Association, 65(330):930–945. doi:10.2307/2284599
Iwashita, T. & Klar, B. (2024). A gamma tail statistic and its asymptotics. Statistica Neerlandica 78:2, 264-280. doi:10.1111/stan.12316
x = rlnorm(2e2, 2, 2) lnorm_tailplot(x, method="unbiased", xscale="o")x = rlnorm(2e2, 2, 2) lnorm_tailplot(x, method="unbiased", xscale="o")
This function computes the estimate of and the associated confidence interval for as well as , the corresponding shape parameter under the assumption of a Pareto model according to Klar (2024). Three methods are implemented to compute the confidence intervals: a method based on the unbiased variance estimators of the underlying U-statistics and two resampling methods (jackknife and bootstrap).
pareto_tail( x, u, confint = FALSE, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95 )pareto_tail( x, u, confint = FALSE, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95 )
x |
a vector containing the sample data. |
u |
the threshold for the computation of t. |
confint |
a boolean value indicating whether the confidence interval should be computed. |
method |
the method used for computing the confidence intervals (options include unbiased variance estimator, jackknife, and bootstrap). |
R |
the number of the bootstrap replicates. |
conf.level |
the confidence level for the interval. |
In Klar (2024) the function
is proposed as a tool for detecting Pareto-type tails, where
are random variables from an absolutely continuous distribution supported on .
Theorem 1 in Klar (2024) shows that is constant in
if and only if has a Pareto distribution.
The estimator can be computed
recursively. For ,
which can be evaluated efficiently starting from
, where denotes the -th order statistic.
Confidence intervals for based on the following methods for variance estimation are also provided:
Unbiased variance estimator
Bootstrap resampling
Jackknife resampling
A two-sided confidence interval
for the estimator is :
where is the appropriate quantile of the standard normal distribution, is an estimator of the standard deviation of , for a constant c specified in section 4.1. of Klar (2024), and
is a U-statistic given by
A matrix containing:
threshold |
The value of the threshold u. |
t.estimate |
Estimate of the tail functional t. |
t.ci1 |
The lower bound of the confidence interval for t (if |
t.ci2 |
The upper bound of the confidence interval for t (if |
alpha |
Estimate of the shape parameter under a Pareto model. |
alpha.ci1 |
The lower bound of the confidence interval for alpha (if |
alpha.ci2 |
The upper bound of the confidence interval for alpha (if |
Klar, B. (2024). A Pareto tail plot without moment restrictions. The American Statistician. doi:10.1080/00031305.2024.2413081
x <- actuar::rpareto1(1e3, shape=1, min=1) pareto_tail(x, round( quantile(x, c(0.1, 0.5, 0.75, 0.9, 0.95, 0.99)) ), confint = FALSE)x <- actuar::rpareto1(1e3, shape=1, min=1) pareto_tail(x, round( quantile(x, c(0.1, 0.5, 0.75, 0.9, 0.95, 0.99)) ), confint = FALSE)
This function produces a tail plot for the estimate over a range of thresholds for a given sample, including confidence intervals computed by one of three methods (unbiased, bootstrap or jackknife). The function also allows a choice between original and log scale.
pareto_tailplot( x, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95, ci.points = 101, xscale = "b" )pareto_tailplot( x, method = c("unbiased", "bootstrap", "jackknife"), R = 1000, conf.level = 0.95, ci.points = 101, xscale = "b" )
x |
a vector containing the sample data. |
method |
the method used for computing the confidence intervals (options include unbiased variance estimator, jackknife, and bootstrap). |
R |
the number of the bootstrap replicates. |
conf.level |
the confidence level for the interval. |
ci.points |
the number of thresholds used in the calculation of the confidence intervals. |
xscale |
the scale of the x-axis (options include "o" = original, "l" = log scale, "b" = both). |
For more details about the estimator and the computation of the confidence intervals see pareto_tail.
A plot showing the estimated versus threshold , optionally on a logarithmic x-axis and including confidence intervals. Note that on the right side of the plot, one can observe the corresponding alpha values, which indicate the shape parameter of the Pareto distribution associated with the estimated t-values.
Klar, B. (2024). A Pareto tail plot without moment restrictions. The American Statistician. doi:10.1080/00031305.2024.2413081
x <- actuar::rpareto1(1e3, shape=1, min=1) pareto_tailplot(x, method="unbiased", xscale="o")x <- actuar::rpareto1(1e3, shape=1, min=1) pareto_tailplot(x, method="unbiased", xscale="o")