Learn R Programming

⚠️There's a newer version (1.5.0) of this package.Take me there.

univariateML

Overview

univariateML is an R-package for user-friendly maximum likelihood estimation of a selection of parametric univariate densities. In addition to basic estimation capabilities, this package support visualization through plot and qqmlplot, model selection by AIC and BIC, confidence sets through the parametric bootstrap with bootstrapml, and convenience functions such as the density, distribution function, quantile function, and random sampling at the estimated distribution parameters.

Installation

Use the following command from inside R to install from CRAN.

install.packages("univariateML")

Or install the development version from Github.

# install.packages("devtools")
devtools::install_github("JonasMoss/univariateML")

Usage

The core of univariateML are the ml*** functions, where *** is a distribution suffix such as norm, gamma, or weibull.

library("univariateML")
mlweibull(egypt$age)
#> Maximum likelihood estimates for the Weibull model 
#>  shape   scale  
#>  1.404  33.564

Now we can visually assess the fit of the Weibull model to the egypt data with a plot.

hist(egypt$age, freq = FALSE, xlab = "Mortality", main = "Egypt")
lines(mlweibull(egypt$age))

Supported densities

NameunivariateML functionPackage
Cauchy distributionmlcauchystats
Gumbel distributionmlgumbelextraDistr
Laplace distributionmllaplaceextraDistr
Logistic distributionmllogisstats
Normal distributionmlnormstats
Student t distributionmlstdfGarch
Generalized Error distributionmlgedfGarch
Skew Normal distributionmlsnormfGarch
Skew Student t distributionmlsstdfGarch
Skew Generalized Error distributionmlsgedfGarch
Beta prime distributionmlbetaprextraDistr
Exponential distributionmlexpstats
Gamma distributionmlgammastats
Inverse gamma distributionmlinvgammaextraDistr
Inverse Gaussian distributionmlinvgaussactuar
Inverse Weibull distributionmlinvweibullactuar
Log-logistic distributionmlllogisactuar
Log-normal distributionmllnormstats
Lomax distributionmllomaxextraDistr
Rayleigh distributionmlrayleighextraDistr
Weibull distributionmlweibullstats
Log-gamma distributionmllgammaactuar
Pareto distributionmlparetoextraDistr
Beta distributionmlbetastats
Kumaraswamy distributionmlkumarextraDistr
Logit-normalmllogitnormlogitnorm
Uniform distributionmlunifstats
Power distributionmlpowerextraDistr

Implementations

Analytic formulae for the maximum likelihood estimates are used whenever they exist. Most ml*** functions without analytic solutions have a custom made Newton-Raphson solver. These can be much faster than a naïve solution using nlm or optim. For example, mlbeta has a large speedup over the naïve solution using nlm.

# install.packages("microbenchmark")
set.seed(313)
x <- rbeta(500, 2, 7)

microbenchmark::microbenchmark(
  univariateML = univariateML::mlbeta(x),
  naive = nlm(function(p) -sum(dbeta(x, p[1], p[2], log = TRUE)), p = c(1, 1)))
#> Unit: microseconds
#>          expr     min       lq      mean   median       uq     max neval
#>  univariateML   259.2   348.75   557.959   447.05   536.40  5103.5   100
#>         naive 15349.1 15978.35 16955.165 16365.45 17082.25 48941.4   100

The maximum likelihood estimators in this package have all been subject to testing, see the tests folder for details.

Documentation

For an overview of the package and its features see the overview vignette. For an illustration of how this package can make an otherwise long and laborious process much simpler, see the copula vignette.

How to Contribute or Get Help

Please read CONTRIBUTING.md for details about how to contribute or get help.

Copy Link

Version

Install

install.packages('univariateML')

Monthly Downloads

1,251

Version

1.1.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Jonas Moss

Last Published

January 25th, 2022

Functions in univariateML (1.1.1)

mlbeta

Beta distribution maximum likelihood estimation
ProbabilityPlots

Probability Plots Using Maximum Likelihood Estimates
confint.univariateML

Confidence Intervals for Maximum Likelihood Estimates
bootstrapml

Parametric Bootstrap on Distributions Fitted with Maximum Likelihood
mlinvweibull

Inverse Weibull distribution maximum likelihood estimation
mlinvgauss

Inverse Gaussian (Wald) maximum likelihood estimation
mlunif

Uniform distribution maximum likelihood estimation
mlllogis

Log-logistic distribution maximum likelihood estimation
mlstd

Student-t distribution maximum likelihood estimation
mllgamma

Log-gamma distribution maximum likelihood estimation
mlinvgamma

Inverse Gamma distribution maximum likelihood estimation
mlbetapr

Beta prime distribution maximum likelihood estimation
mlrayleigh

Rayleigh distribution maximum likelihood estimation
mlgamma

Gamma distribution maximum likelihood estimation
ml_input_checker

Input Checker for ML functions
listmerge

Merges two lists.
mlged

Generalized Error distribution maximum likelihood estimation
mlcauchy

Cauchy distribution maximum likelihood estimation
univariateML_to_function

Transform a univariateML object to a quantile, CDF, density or random variate generation.
univariateML_to_string

Transform a univariateML object to a string specifying quantile, CDF, density or random variate generation.
mlsged

Skew Generalized Error distribution maximum likelihood estimation
mlexp

Exponential distribution maximum likelihood estimation
mlweibull

Weibull distribution maximum likelihood estimation
mllnorm

Log-normal distribution maximum likelihood estimation
mllogis

Logistic distribution maximum likelihood estimation
model_select

Fit multiple models and select the best fit
mlpareto

Pareto distribution maximum likelihood estimation
ppqq_wrangler

Wrangles arguments for use in ppml and qqml functions.
mllogitnorm

Logit-Normal distribution maximum likelihood estimation
mllomax

Lomax distribution maximum likelihood estimation
egypt

Mortality data from ancient Egypt
mlpower

Power distribution maximum likelihood estimation
plot.univariateML

Plot, Lines and Points Methods for Maximum Likelihood Estimates
to_univariateML

Data and function to 'univariateML'
plot_wrangler

Wrangles arguments for use in the plot, lines and points functions.
univariateML-package

univariateML
mlsstd

Skew Student t-distribution maximum likelihood estimation
mlsnorm

Skew Normal distribution maximum likelihood estimation
univariateML_models

Implemented models
mlnaka

Nakagami distribution maximum likelihood estimation
mlkumar

Kumaraswamy distribution maximum likelihood estimation
mllaplace

Laplace distribution maximum likelihood estimation
mlnorm

Normal distribution maximum likelihood estimation
MaximumLikelihoodDistribution

Maximum likelihood estimated distribution
abalone

Abalone data
mlgumbel

Gumbel distribution maximum likelihood estimation