MyNixOS website logo
Description

Estimators and Algorithms for Heavy-Tailed Distributions.

Implements the estimators and algorithms described in Chapters 8 and 9 of the book "The Fundamentals of Heavy Tails: Properties, Emergence, and Estimation" by Nair et al. (2022, ISBN:9781009053730). These include the Hill estimator, Moments estimator, Pickands estimator, Peaks-over-Threshold (POT) method, Power-law fit, and the Double Bootstrap algorithm.

heavytails

Estimators, diagnostics, and goodness-of-fit tools for heavy-tailed distributions in R.

heavytails implements the estimators and algorithms from The Fundamentals of Heavy Tails: Properties, Emergence, and Estimation (Nair, Wierman & Zwart, 2022) — Chapters 8 and 9. It covers tail index estimation, visual diagnostics, Pareto model fitting, and a complete goodness-of-fit pipeline, all using base R with no heavy dependencies.

Installation

From CRAN:

install.packages("heavytails")

Development version from GitHub:

# install.packages("remotes")
remotes::install_github("0diraf/heavytails")

Quick Example

library(heavytails)

set.seed(1)
x <- rpareto(n = 1000, alpha = 2, xm = 1)

# Tail index estimation
hill_estimator(x, k = 50)
mle_pareto(x)

# Visual diagnostics
hill_plot(x)
rank_plot(x)

# Goodness-of-fit pipeline
fit  <- plfit(x)
xmin <- fit$xmin
alph <- fit$alpha

ks_gof(x, alpha = alph, xm = xmin, n_boot = 500)
lr_test_pareto(x, alpha = alph, xmin = xmin)

Functions

Tail Index Estimators

FunctionDescriptionReference
hill_estimator()Hill (1975) MLE on top-k order statisticsCh. 9, §9.2
moments_estimator()Dekkers-Einmahl-de Haan (1989) moments estimatorCh. 9, §9.3
pickands_estimator()Pickands (1975) spacing-based estimatorCh. 9, §9.3
pot_estimator()GPD fit via MLE on excesses over threshold uCh. 9, §9.4
plfit()KS-minimization for optimal k̂ and α̂ (Clauset et al. 2009)Ch. 9, §9.5
doublebootstrap()Automatic k selection via double bootstrap (Danielsson et al. 2001)Ch. 9, §9.5

Pareto Estimation

FunctionDescription
mle_pareto()Parametric MLE for Pareto(xm, α) with optional bias correction
wls_pareto()Weighted least-squares log-rank regression estimator
ks_xmin()KS-based selection of the optimal xmin threshold

Visual Diagnostics

FunctionDescription
hill_plot()Hill plot: α̂ vs. k to assess stability
moments_plot()Moments estimator plot: ξ̂ vs. k
pickands_plot()Pickands estimator plot: ξ̂ vs. k
rank_plot()Log-rank vs. log-x plot for Pareto linearity
qq_pareto()Pareto Q-Q plot

All plot functions return the underlying data.frame invisibly, so results can be captured for custom plotting with ggplot2 or base R.

Goodness-of-Fit

FunctionDescription
ks_gof()Bootstrap KS test for Pareto fit
lr_test_pareto()Likelihood-ratio test: Pareto vs. alternative distributions

Pareto Utilities

FunctionDescription
rpareto()Generate Pareto(xm, α) random variates
pareto_cdf()Pareto CDF
dpareto()Pareto density

Example: Hill Plot

A Hill plot shows how the tail index estimate changes with k. Stability across a range of k values is evidence that the tail is power-law distributed.

library(heavytails)

set.seed(42)
x <- rpareto(n = 2000, alpha = 1.5, xm = 1)

hill_plot(x, alpha_true = 1.5,
          main = "Hill Plot", col = "steelblue")

The dashed red line (when alpha_true is supplied) marks the true value for simulation studies.

Example: Full Clauset et al. Pipeline

library(heavytails)

set.seed(1)
x <- rpareto(n = 1000, alpha = 2, xm = 1)

# Step 1: estimate xmin and alpha
fit <- plfit(x)

# Step 2: goodness-of-fit test
gof <- ks_gof(x, alpha = fit$alpha, xm = fit$xmin, n_boot = 1000)
gof$p_value   # > 0.1 → cannot reject Pareto

# Step 3: compare against alternative distributions
lr_test_pareto(x, alpha = fit$alpha, xmin = fit$xmin)

Reference

Nair, J., Wierman, A., & Zwart, B. (2022). The Fundamentals of Heavy Tails: Properties, Emergence, and Estimation. Cambridge University Press. doi:10.1017/9781009053730

License

MIT.

Metadata

Version

0.2.0

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows