Abstract: The gk package for R provides a comprehensive suite of tools for the g-and-k and g-and-h distribution families. These distributions are defined by their quantile functions and are particularly useful for modeling data with significant skewness and heavy tails. The package includes standard distribution functions (PDF, CDF, quantiles) and advanced inference methods such as Approximate Bayesian Computation (ABC) and Markov Chain Monte Carlo (MCMC).
Introduction
Real-world datasets in fields like finance and environmental science often deviate from the Normal distribution, exhibiting heavy tails and skewness. The g-and-k and g-and-h distributions address this by incorporating parameters for location ($A$), scale ($B$), skewness ($g$), and kurtosis ($k$ or $h$). However, because these distributions are defined via quantile functions and lack closed-form probability density functions (PDFs), traditional estimation methods like Maximum Likelihood Estimation (MLE) are computationally demanding. The gk package, authored by Dennis Prangle, provides efficient implementations and "likelihood-free" inference methods to overcome these challenges.
Methods
The package implements several core functionalities to facilitate the use of these flexible distributions.
Standard Distribution Functions
The package provides standard R-style functions (d, p, q, r) for both distribution families. The density (d) and distribution (p) functions are computed through numerical inversion of the quantile function.
Approximate Bayesian Computation (ABC)
ABC is a "likelihood-free" inference method that compares simulated data from the model to observed data using summary statistics. This avoids the need for complex density calculations, making it ideal for quantile-defined distributions.
Other methods include Markov Chain Monte Carlo (MCMC) using an adaptive Metropolis algorithm for full Bayesian inference, and Finite Difference Stochastic Approximation (FDSA) for gradient-free optimization to find MLEs.
Key Insights and Ideas
The gk package emphasizes quantile-first modeling, allowing for highly flexible distribution shapes by transforming standard normal variables. A significant efficiency gain in the abc implementation is achieved by using octiles as summary statistics, which often outperforms using full order statistics for parameter estimation. By automating the "heavy lifting" of inverting quantile functions, the package removes the primary barrier to using these distributions in standard statistical software.
Results and Applications
The package offers a unified interface for Tukey’s g-and-h, Generalized g-and-h, and g-and-k distributions. The inclusion of fdsa and abc allows users to perform robust parameter estimation even when the data size is large or the density is difficult to evaluate. Practical applications include the analysis of exchange rate data, where heavy tails are a common feature.
Limitations
While powerful, the package has some computational overhead due to the numerical inversion required for density and distribution functions. Additionally, optimization methods like FDSA can be sensitive to initial values, and the isValid function may occasionally produce false positives regarding the monotonicity of the quantile function. Users are encouraged to use multiple starting points for optimization to ensure robust results.
Summary updated