Title: | Maximum Likelihood Estimation for Univariate Densities |
---|---|
Description: | User-friendly maximum likelihood estimation (Fisher (1921) <doi:10.1098/rsta.1922.0009>) of univariate densities. |
Authors: | Jonas Moss [aut, cre] , Thomas Nagler [ctb], Chitu Okoli [ctb] |
Maintainer: | Jonas Moss <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.5.0 |
Built: | 2025-01-31 05:41:31 UTC |
Source: | https://github.com/jonasmoss/univariateml |
An R
-package for fast, easy, and reliable maximum likelihood
estimation for a selection of parametric univariate densities.
Data analysis often requires the estimation of univariate densities. Maximum likelihood estimation is sensible for almost every univariate density used in practice. Moreover, the maximum likelihood estimator is typically consistent and efficient.
The purpose of this package is to
Support maximum likelihood estimation of a large selection of densities.
Supports plenty of generics such as plot
and AIC
to
aid your data analysis.
Read the vignettes to learn more about univariateML:
browseVignettes(package = "univariateML")
Maintainer: Jonas Moss [email protected] (ORCID)
Other contributors:
Thomas Nagler [email protected] [contributor]
Chitu Okoli [email protected] [contributor]
Useful links:
Report bugs at https://github.com/JonasMoss/univariateML/issues
Physical measurements of 4177 abalones, a species of sea snail.
abalone
abalone
A tibble with 4,177 observations and 9 variables:
Sex of the abalone, F
is female, M
male, and
I
infant.
Longest shell measurement.
Diameter perpendicular to length.
Height with with meat in shell.
Grams whole abalone.
Grams weight of meat.
Grams gut weight (after bleeding).
Grams after being dried.
+1.5 gives the age in years.
See the web page https://archive.ics.uci.edu/ml/datasets/Abalone for more information about the data set.
Dua, D. and Graff, C. (2019). UCI Machine Learning Repository https://archive.ics.uci.edu/ml/. Irvine, CA: University of California, School of Information and Computer Science.
Ko, V., Hjort, N. L., & Hobaek Haff, I. (2019). Focused information criteria for copulas. Scandinavian Journal of Statistics.
abalone
abalone
The parametric bootstrap is a resampling technique using random variates
from a known parametric distribution. In this function the distribution
of the random variates is completely determined by the unvariateML
object object
.
bootstrapml( object, reps = 1000, map = identity, reducer = stats::quantile, ... )
bootstrapml( object, reps = 1000, map = identity, reducer = stats::quantile, ... )
object |
A |
reps |
Positive integer. The number of bootstrap samples. |
map |
A function of the parameters of the |
reducer |
A reducer function. Defaults to |
... |
Passed to |
For each bootstrap iteration a maximum likelihood estimate is calculated
using the ml***
function specified by object
. The resulting
numeric vector is then passed to map
. The values returned by
map
is collected in an array and the reducer
is called on
each row of the array.
By default the map
function is the identity and the default
reducer
is the quantile function taking the argument probs
,
which defaults to c(0.025, 0.975)
. This corresponds to a 95\
basic percentile confidence interval and is also reported by
confint()
Note: The default confidence intervals are percentile intervals, not empirical intervals. These confidence intervals will in some cases have poor coverage as they are not studentized, see e.g. Carpenter, J., & Bithell, J. (2000).
The transposed map-reduced bootstrap samples.
Efron, B., & Tibshirani, R. J. (1994). An introduction to the bootstrap. CRC press.
Carpenter, J., & Bithell, J. (2000). Bootstrap confidence intervals: when, which, what? A practical guide for medical statisticians. Statistics in medicine, 19(9), 1141-1164.
confint()
for an application of bootstrapml
.
set.seed(1) object <- mlgamma(mtcars$qsec) ## Calculate c(0.025, 0.975) confidence interval for the gamma parameters. bootstrapml(object) # 2.5% 97.5% # shape 68.624945 160.841557 # rate 3.896915 9.089194 ## The mean of a gamma distribution is shape/rate. Now we calculate a ## parametric bootstrap confidence interval for the mean with confidence ## limits c(0.05, 0.95) bootstrapml(object, map = \(x) x[1] / x[2], probs = c(0.05, 0.95)) # 5% 95% # 17.33962 18.31253 ## Print a histogram of the bootstrapped estimates from an exponential. object <- mlexp(mtcars$qsec) hist(bootstrapml(object, reducer = identity))
set.seed(1) object <- mlgamma(mtcars$qsec) ## Calculate c(0.025, 0.975) confidence interval for the gamma parameters. bootstrapml(object) # 2.5% 97.5% # shape 68.624945 160.841557 # rate 3.896915 9.089194 ## The mean of a gamma distribution is shape/rate. Now we calculate a ## parametric bootstrap confidence interval for the mean with confidence ## limits c(0.05, 0.95) bootstrapml(object, map = \(x) x[1] / x[2], probs = c(0.05, 0.95)) # 5% 95% # 17.33962 18.31253 ## Print a histogram of the bootstrapped estimates from an exponential. object <- mlexp(mtcars$qsec) hist(bootstrapml(object, reducer = identity))
Computes a confidence interval for one or more parameters in a
unvariateML
object.
## S3 method for class 'univariateML' confint(object, parm = NULL, level = 0.95, Nreps = 1000, ...)
## S3 method for class 'univariateML' confint(object, parm = NULL, level = 0.95, Nreps = 1000, ...)
object |
An object of class |
parm |
Vector of strings; the parameters to calculate a confidence
interval for. Each parameter must be a member of |
level |
The confidence level. |
Nreps |
Number of bootstrap iterations. Passed to
|
... |
Additional arguments passed to |
confint.univariateML
is a wrapper for bootstrapml()
that
computes confidence intervals for the main parameters of object
.
The main parameters of object
are the members of
names(object)
. For instance, the main parameters of an object
obtained from mlnorm
are mean
and sd
. The
confidence intervals are parametric bootstrap percentile intervals
with limits (1-level)/2
and 1 - (1-level)
.
A matrix or vector with columns giving lower and upper confidence
limits for each parameter in parm
.
stats::confint()
for the generic function and
bootstrapml()
for the function used to calculate the
confidence intervals.
object <- mlinvgauss(airquality$Wind) confint(object) # 95% confidence interval for mean and shape confint(object, "mean") # 95% confidence interval for the mean parameter # confint(object, "variance") # Fails since 'variance isn't a main parameter.
object <- mlinvgauss(airquality$Wind) confint(object) # 95% confidence interval for mean and shape confint(object, "mean") # 95% confidence interval for the mean parameter # confint(object, "variance") # Fails since 'variance isn't a main parameter.
Species abundance data from 1943; a classical application of the logarithmic series distribution.
corbet
corbet
A vector of size 501 containing integer observations between 1 and 24.
Fisher, R. A., Corbet, A. S., & Williams, C. B. (1943). The relation between the number of species and the number of individuals in a random sample of an animal population. The Journal of Animal Ecology, 12(1), 42. https://doi.org/10.2307/1411
corbet
corbet
Age at death of 141 Roman era Egyptian mummies.
egypt
egypt
A tibble with 141 observations and 2 variables:
Age at death.
Sex of deceased; 82 males and 49 females.
This data was collected by Spiegelberg (1901) and analyzed by Karl Pearson (1902) in the first volume of Biometrika. It was analyzed by Claeskens & Hjort (2008) and the data is based on their transcription.
Spiegelberg, W. (1901). Aegyptische und Griechische Eigennamen aus Mumientiketten der R<U+00F6>mischen Kaiserzeit.
Pearson, K. (1902). On the change in expectation of life in man during a period of circa 2000 years. Biometrika, 1(2), 261-264.
Claeskens, G., & Hjort, N. L. (2008). Model selection and model averaging. Cambridge University Press.
The source of the data is https://feb.kuleuven.be/public/u0043181/modelselection/datasets/egyptlives_data.txt
egypt
egypt
Density, distribution function, quantile function and random generation for a univariate distribution estimated by maximum likelihood.
dml(x, obj, log = FALSE) pml(q = q, obj, lower.tail = TRUE, log.p = FALSE) qml(p = p, obj, lower.tail = TRUE, log.p = FALSE) rml(n = n, obj)
dml(x, obj, log = FALSE) pml(q = q, obj, lower.tail = TRUE, log.p = FALSE) qml(p = p, obj, lower.tail = TRUE, log.p = FALSE) rml(n = n, obj)
x , q
|
vector of quantiles. |
obj |
an |
log , log.p
|
logical; if |
lower.tail |
logical; if |
p |
vector of probabilities. |
n |
number of observations. If |
dml
is the density, pml
is the distribution function,
qml
is the quantile function, and rml
is the random variable
generator.
These functions work like their counterparts in stats
, e.g.
Normal. The univariateML
object contains both maximum
likelihood estimates and the identity of the model these estimates were
calculated under. These functions are wrappers around underlying density,
distribution, quantile and random generation functions where unknown
parameters are filled with the maximum likelihood estimates.
See the example.
dml
gives the density, pml
gives the distribution
function, qml
gives the quantile function, and rml
generates random deviates.
## Simple example obj <- mlnorm(airquality$Wind) dml(0.5, obj) == dnorm(0.5, mean = obj[1], sd = obj[2]) obj <- mlbetapr(airquality$Wind) # Plot the logarithm of the beta prime distribution. plot(\(x) dml(x, obj, log = TRUE), from = 0, to = 20, main = "Logarithm of Density", ylab = NA, lwd = 2 )
## Simple example obj <- mlnorm(airquality$Wind) dml(0.5, obj) == dnorm(0.5, mean = obj[1], sd = obj[2]) obj <- mlbetapr(airquality$Wind) # Plot the logarithm of the beta prime distribution. plot(\(x) dml(x, obj, log = TRUE), from = 0, to = 20, main = "Logarithm of Density", ylab = NA, lwd = 2 )
Uses stat::nlm
to estimate the parameters of the Beta distribution.
mlbeta(x, na.rm = FALSE, ...)
mlbeta(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
|
For the density function of the Beta distribution see Beta.
For type
, the option none
is fastest.
mlbeta
returns an object of class
univariateML
. This is a named numeric vector with maximum
likelihood estimates for shape1
and shape2
and the
following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 2, Chapter 25. Wiley, New York.
Beta for the Beta density, nlm for the optimizer this function uses.
AIC(mlbeta(USArrests$Rape / 100))
AIC(mlbeta(USArrests$Rape / 100))
This function does not estimate the scale parameter for the BetaPrime
distribution. Transforms the data and uses stat::nlm
to estimate
the parameters of the Beta distribution.
mlbetapr(x, na.rm = FALSE, ...)
mlbetapr(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
passed to |
For the density function of the Beta prime distribution see BetaPrime.
For type
, the option none
is fastest.
mlbetapr
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
shape1
and shape2
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 2, Chapter 25. Wiley, New York.
BetaPrime for the Beta prime density, nlm for the optimizer this function uses, mlbeta for the Beta distribution maximum likelihood estimator.
AIC(mlbetapr(USArrests$Rape))
AIC(mlbetapr(USArrests$Rape))
For the density function of the Binomial distribution see Binomial.
mlbinom(x, na.rm = FALSE, ...)
mlbinom(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
The arguments |
The estimator computes both the size
and prob
parameter by default. Be aware
that the likelihood will often be unbounded. According to Olkin et al. (1981),
the likelihood is unbounded when ,
where
is the biased sample variance. When the likelihood
is unbounded,the maximum likelihood estimator can be regarded as a Poisson
with
lambda
parameter equal to the mean of the observation.
When and
size
is not supplied by the user,
an error is cast. If size
is provided and size < max(x)
, an error is cast.
The maximum likelihood estimator of size
is unstable, and improvements exist.
See, e.g., Carroll and Lomard (1985) and DasGupta and Rubin (2005).
mlbinom
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
size
and prob
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Olkin, I., Petkau, A. J., & Zidek, J. V. (1981). A comparison of n Estimators for the binomial distribution. Journal of the American Statistical Association, 76(375), 637-642. https://doi.org/10.1080/01621459.1981.10477697
Johnson, N. L., Kemp, A. W., & Kotz, S. (2005). Univariate Discrete Distributions (3rd ed.). Wiley-Blackwell.
Carroll, R. J., & Lombard, F. (1985). A Note on N Estimators for the Binomial Distribution. Journal of the American Statistical Association, 80(390), 423-426. https://doi.org/10.1080/01621459.1985.10478134
DasGupta, A., & Rubin, H. (2005). Estimation of binomial parameters when both n,p are unknown. Journal of Statistical Planning and Inference, 130(1-2), 391-404. https://doi.org/10.1016/j.jspi.2004.02.019
Binomial for the density.
# The likelihood will often be unbounded. ## Not run: mlbinom(ChickWeight$weight) ## End(Not run) # Provide a size mlbinom(ChickWeight$weight, size = 400) # Or use mlpoiss, the limiting likelihood of the binomial. mlpois(ChickWeight$weight)
# The likelihood will often be unbounded. ## Not run: mlbinom(ChickWeight$weight) ## End(Not run) # Provide a size mlbinom(ChickWeight$weight, size = 400) # Or use mlpoiss, the limiting likelihood of the binomial. mlpois(ChickWeight$weight)
Calculates the estimates using nlm
and an exponential transform of the
location parameter. If n < 5
, an exact solution is reported. In
the edge case where no maximum likelihood estimator exists and error is
thrown.
mlcauchy(x, na.rm = FALSE, ...)
mlcauchy(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Cauchy distribution see Cauchy.
mlcauchy
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
location
and scale
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 16. Wiley, New York.
Cauchy for the Cauchy density, nlm for the optimizer this function uses.
mlcauchy(airquality$Temp)
mlcauchy(airquality$Temp)
The maximum likelihood estimate of rate
is the inverse sample mean.
mlexp(x, na.rm = FALSE, ...)
mlexp(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? If |
... |
currently affects nothing. |
For the density function of the exponential distribution see Exponential.
mlexp
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
rate
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured by |
continuous |
Is the density continuous or discrete? |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 19. Wiley, New York.
Exponential for the exponential density.
mlexp(precip)
mlexp(precip)
Uses Newton-Raphson to estimate the parameters of the Gamma distribution.
mlgamma(x, na.rm = FALSE, ...)
mlgamma(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
|
For the density function of the Gamma distribution see GammaDist.
mlgamma
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
shape
and rate
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Choi, S. C, and R. Wette. "Maximum likelihood estimation of the parameters of the gamma distribution and their bias." Technometrics 11.4 (1969): 683-690.
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 17. Wiley, New York.
GammaDist for the Gamma density.
mlgamma(precip)
mlgamma(precip)
Joint maximum likelihood estimation as implemented by fGarch::gedFit.
mlged(x, na.rm = FALSE, ...)
mlged(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Student t-distribution see ged.
mlged
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for the
parameters mean
, sd
, nu
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Nelson D.B. (1991); Conditional Heteroscedasticity in Asset Returns: A New Approach, Econometrica, 59, 347<U+2013>370.
Fernandez C., Steel M.F.J. (2000); On Bayesian Modelling of Fat Tails and Skewness, Preprint.
ged for the Student t-density.
mlged(precip)
mlged(precip)
For the density function of the Geometric distribution see Geometric.
mlgeom(x, na.rm = FALSE, ...)
mlgeom(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
not in use. |
mlgeom
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
prob
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kemp, A. W., & Kotz, S. (2005). Univariate Discrete Distributions (3rd ed.). Wiley-Blackwell.
Geometric for the density.
mlgeom(corbet)
mlgeom(corbet)
Uses Newton-Raphson to estimate the parameters of the Gumbel distribution.
mlgumbel(x, na.rm = FALSE, ...)
mlgumbel(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
|
For the density function of the Gumbel distribution see Gumbel.
mlgumbel
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for mu
and s
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
shape
and sigma
.
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 2, Chapter 22. Wiley, New York.
Gumbel for the Gumbel density.
mlgumbel(precip)
mlgumbel(precip)
Transforms the data and uses Newton-Raphson to estimate the parameters of the Gamma distribution.
mlinvgamma(x, na.rm = FALSE, ...)
mlinvgamma(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
passed to |
For the density function of the inverse Gamma distribution see InvGamma.
A named numeric vector with maximum likelihood estimates for
alpha
and beta
.
Choi, S. C, and R. Wette. "Maximum likelihood estimation of the parameters of the gamma distribution and their bias." Technometrics 11.4 (1969): 683-690.
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 17. Wiley, New York.
Witkovsky, V. (2001). "Computing the Distribution of a Linear Combination of Inverted Gamma Variables". Kybernetika. 37 (1): 79<U+2013>90
InvGamma for the Inverse Gamma density.
mlinvgamma(precip)
mlinvgamma(precip)
The maximum likelihood estimate of mean
is the empirical mean and the
maximum likelihood estimate of 1/shape
is the difference between
the mean of reciprocals and the reciprocal of the mean.
mlinvgauss(x, na.rm = FALSE, ...)
mlinvgauss(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Inverse Gamma distribution see InverseGaussian.
mlinvgauss
returns an object of class
univariateML
. This is a named numeric vector with maximum likelihood
estimates for mean
and shape
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 15. Wiley, New York.
InverseGaussian for the Inverse Gaussian density.
mlinvgauss(precip)
mlinvgauss(precip)
The maximum likelihood estimate of shape
and rate
are calculated
by calling mlweibull
on the transformed data.
mlinvweibull(x, na.rm = FALSE, ...)
mlinvweibull(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
passed to |
For the density function of the log normal distribution see InverseWeibull.
mlinvweibull
returns an object of class
univariateML
. This is a named numeric vector with maximum likelihood
estimates for shape
and rate
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Kleiber, C. and Kotz, S. (2003), Statistical Size Distributions in Economics and Actuarial Sciences, Wiley.
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (2012), Loss Models, From Data to Decisions, Fourth Edition, Wiley.
Dutang, C., Goulet, V., & Pigeon, M. (2008). actuar: An R package for actuarial science. Journal of Statistical Software, 25(7), 1-37.
InverseWeibull for the Inverse Weibull density.
mlinvweibull(precip)
mlinvweibull(precip)
Uses Newton-Raphson to estimate the parameters of the Kumaraswamy distribution.
mlkumar(x, na.rm = FALSE, ...)
mlkumar(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
|
For the density function of the Kumaraswamy distribution see Kumaraswamy.
mlkumar
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for a
and b
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Jones, M. C. "Kumaraswamy's distribution: A beta-type distribution with some tractability advantages." Statistical Methodology 6.1 (2009): 70-81.
Kumaraswamy, Ponnambalam. "A generalized probability density function for double-bounded random processes." Journal of Hydrology 46.1-2 (1980): 79-88.
Kumaraswamy for the Kumaraswamy density.
AIC(mlkumar(USArrests$Rape / 100))
AIC(mlkumar(USArrests$Rape / 100))
The maximum likelihood estimate of mu
is the sample median while the
maximum likelihood estimate of sigma
is mean absolute deviation
from the median.
mllaplace(x, na.rm = FALSE, ...)
mllaplace(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Laplace distribution see Laplace.
mllaplace
returns an object of class
univariateML
. This is a named numeric vector with maximum likelihood
estimates for mu
and sigma
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 2, Chapter 24. Wiley, New York.
Laplace for the Laplace density.
mllaplace(precip)
mllaplace(precip)
The maximum likelihood estimate of shapelog
and ratelog
are calculated
by calling mlgamma()
on the transformed data.
mllgamma(x, na.rm = FALSE, ...)
mllgamma(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
passed to |
For the density function of the log normal distribution see Loggamma.
mllgamma
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
shapelog
and ratelog
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Hogg, R. V. and Klugman, S. A. (1984), Loss Distributions, Wiley.
Dutang, C., Goulet, V., & Pigeon, M. (2008). actuar: An R package for actuarial science. Journal of Statistical Software, 25(7), 1-37.
Loggamma for the log normal density.
mllgamma(precip)
mllgamma(precip)
For the density function of the Logarithmic series distribution see Logarithmic series. For an example data set, see corbet.
mllgser(x, na.rm = FALSE, ...)
mllgser(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
Not in use. |
mllgser
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
theta
.
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Fisher, R. A., Corbet, A. S., & Williams, C. B. (1943). The relation between the number of species and the number of individuals in a random sample of an animal population. The Journal of Animal Ecology, 12(1), 42. https://doi.org/10.2307/1411
Johnson, N. L., Kemp, A. W., & Kotz, S. (2005). Univariate Discrete Distributions (3rd ed.). Wiley-Blackwell.
Logarithmic series for the density.
theta_hat <- mllgser(corbet) # The corbert data contains observations from 1 to 24. observed <- table(corbet) # The chi square test evaluated at the maximum likelihood is highly significant. expected <- extraDistr::dlgser(1:24, theta_hat) chisq.test(observed, p = expected / sum(expected)) # But chi square test evaluated at 0.997 (used in Corbet) is not. expected <- extraDistr::dlgser(1:24, 0.997) chisq.test(observed, p = expected / sum(expected)) # The chi square for `dzipf` is similar. expected <- sads::dzipf(1:24, mlzipf(corbet)[1], mlzipf(corbet)[2]) * length(corbet) chisq.test(observed, p = expected / sum(expected))
theta_hat <- mllgser(corbet) # The corbert data contains observations from 1 to 24. observed <- table(corbet) # The chi square test evaluated at the maximum likelihood is highly significant. expected <- extraDistr::dlgser(1:24, theta_hat) chisq.test(observed, p = expected / sum(expected)) # But chi square test evaluated at 0.997 (used in Corbet) is not. expected <- extraDistr::dlgser(1:24, 0.997) chisq.test(observed, p = expected / sum(expected)) # The chi square for `dzipf` is similar. expected <- sads::dzipf(1:24, mlzipf(corbet)[1], mlzipf(corbet)[2]) * length(corbet) chisq.test(observed, p = expected / sum(expected))
The maximum likelihood estimate of shape
and rate
are calculated
by transforming the data back to the logistic model and applying
mllogis
.
mlllogis(x, na.rm = FALSE, ...)
mlllogis(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
passed to |
For the density function of the log-logistic distribution see Loglogistic
mllogis
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
shape
and rate
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Kleiber, C. and Kotz, S. (2003), Statistical Size Distributions in Economics and Actuarial Sciences, Wiley.
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (2012), Loss Models, From Data to Decisions, Fourth Edition, Wiley.
Dutang, C., Goulet, V., & Pigeon, M. (2008). actuar: An R package for actuarial science. Journal of Statistical Software, 25(7), 1-37.
Loglogistic for the log-logistic density.
mllnorm(precip)
mllnorm(precip)
The maximum likelihood estimate of meanlog
is the empirical mean of the
log-transformed data and the maximum likelihood estimate of sdlog
is the square root of the biased sample variance based on the
log-transformed data.
mllnorm(x, na.rm = FALSE, ...)
mllnorm(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the log normal distribution see Lognormal.
mllnorm
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
meanlog
and sdlog
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 14. Wiley, New York.
Lognormal for the log normal density.
mllnorm(precip)
mllnorm(precip)
Calculates the estimates using nlm
with an exponential transform of the
location parameter.
mllogis(x, na.rm = FALSE, ...)
mllogis(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the logistic distribution see Logistic.
mllogis
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
location
and scale
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 2, Chapter 23. Wiley, New York.
Logistic for the Logistic density, nlm for the optimizer this function uses.
mllogis(precip)
mllogis(precip)
The maximum likelihood estimate of mu
is the empirical mean of the
logit transformed data and the maximum likelihood estimate of
sigma
is the square root of the logit transformed
biased sample variance.
mllogitnorm(x, na.rm = FALSE, ...)
mllogitnorm(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the logit-normal distribution see dlogitnorm.
mllogitnorm
returns an object of class
univariateML
. This is a named numeric vector with maximum likelihood
estimates for mu
and sigma
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Atchison, J., & Shen, S. M. (1980). Logistic-normal distributions: Some properties and uses. Biometrika, 67(2), 261-272.
Normal for the normal density.
AIC(mllogitnorm(USArrests$Rape / 100))
AIC(mllogitnorm(USArrests$Rape / 100))
Uses Newton-Raphson to estimate the parameters of the Lomax distribution.
mllomax(x, na.rm = FALSE, ...)
mllomax(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
|
For the density function of the Lomax distribution see Lomax.
The likelihood estimator of the Lomax distribution may be unbounded. When this
happens, the likelihood converges to an exponential distribution with parameter
equal to the mean of the data. This is the natural limiting case for the Lomax
distribution, and it is reasonable to use mlexp
in this case. See
vignette("Distribution Details", package = "univariateML")
for details.
mllomax
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
lambda
and kappa
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Kleiber, Christian; Kotz, Samuel (2003), Statistical Size Distributions in Economics and Actuarial Sciences, Wiley Series in Probability and Statistics, 470, John Wiley & Sons, p. 60
Lomax for the Lomax density.
set.seed(3) mllomax(extraDistr::rlomax(100, 2, 4)) # The maximum likelihood estimator may fail if the data is exponential. ## Not run: set.seed(5) mllomax(rexp(10)) ## End(Not run)
set.seed(3) mllomax(extraDistr::rlomax(100, 2, 4)) # The maximum likelihood estimator may fail if the data is exponential. ## Not run: set.seed(5) mllomax(rexp(10)) ## End(Not run)
The maximum likelihood estimates of shape
and scale
are calculated by
calling mlgamma
on the transformed data.
mlnaka(x, na.rm = FALSE, ...)
mlnaka(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
passed to |
For the density function of the Nakagami distribution see Nakagami.
mlgamma
returns an object of class
univariateML
. This is a named numeric vector with maximum
likelihood estimates for shape
and rate
and the following
attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured by |
continuous |
Is the density continuous or discrete? |
Choi, S. C, and R. Wette. "Maximum likelihood estimation of the parameters of the gamma distribution and their bias." Technometrics 11.4 (1969): 683-690.
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 17. Wiley, New York.
Nakagami for the Nakagami distribution.
GammaDist for the closely related Gamma density.
See mlgamma
for the machinery underlying this function.
mlgamma(precip)
mlgamma(precip)
For the density function of the Negative binomial distribution see Negative binomial.
mlnbinom(x, na.rm = FALSE, ...)
mlnbinom(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
The arguments |
mlnbinom
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
size
and prob
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kemp, A. W., & Kotz, S. (2005). Univariate Discrete Distributions (3rd ed.). Wiley-Blackwell.
Negative binomial for the density.
mlnbinom(corbet)
mlnbinom(corbet)
The maximum likelihood estimate of mean
is the empirical mean and the
maximum likelihood estimate of sd
is the square root of the
biased sample variance.
mlnorm(x, na.rm = FALSE, ...)
mlnorm(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the normal distribution see Normal.
mlnorm
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
mean
and sd
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 13. Wiley, New York.
Normal for the normal density.
mlnorm(precip)
mlnorm(precip)
The maximum likelihood estimate of b
is the minimum of x
and the
maximum likelihood estimate of a
is
1/(mean(log(x)) - log(b))
.
mlpareto(x, na.rm = FALSE, ...)
mlpareto(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Pareto distribution see Pareto.
mlpareto
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
a
and b
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 20. Wiley, New York.
Pareto for the Pareto density.
mlpareto(precip)
mlpareto(precip)
The maximum likelihood estimate of lambda
is the empirical mean.
mlpois(x, na.rm = FALSE, ...)
mlpois(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Poisson distribution see Poisson.
mlpois
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
lambda
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kemp, A. W., & Kotz, S. (2005). Univariate Discrete Distributions (3rd ed.). Wiley-Blackwell.
Poisson for the Poisson density.
mlpois(ChickWeight$weight)
mlpois(ChickWeight$weight)
The maximum likelihood estimate of alpha
is the maximum of x
+
epsilon
(see the details) and the maximum likelihood estimate of
beta
is 1/(log(alpha)-mean(log(x)))
.
mlpower(x, na.rm = FALSE, ...)
mlpower(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
|
For the density function of the power distribution see
PowerDist. The maximum likelihood estimator of
alpha
does not exist, strictly
speaking. This is because x
is supported c(0, alpha)
with
an open endpoint on alpha in the extraDistr
implementation of
dpower
. If the endpoint was closed, max(x)
would have been
the maximum likelihood estimator. To overcome this problem, we add
a possibly user specified epsilon
to max(x)
.
mlpower
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
alpha
and beta
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Arslan, G. "A new characterization of the power distribution." Journal of Computational and Applied Mathematics 260 (2014): 99-102.
PowerDist for the power density. extraDistr::Pareto for the closely related Pareto distribution.
mlpower(precip)
mlpower(precip)
Calculates the sigma
parameter as the square root of half the
empirical second moment.
mlrayleigh(x, na.rm = FALSE, ...)
mlrayleigh(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Rayleigh distribution see Rayleigh.
mlrayleigh
returns an object of class
univariateML
. This is a named numeric vector with maximum likelihood
estimates for sigma
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 18. Wiley, New York.
Rayleigh for the Rayleigh density.
mlrayleigh(precip)
mlrayleigh(precip)
Joint maximum likelihood estimation as implemented by fGarch::sgedFit.
mlsged(x, na.rm = FALSE, ...)
mlsged(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Student t-distribution see sged.
mlsged
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for the
parameters mean
, sd
, nu
, xi
, and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Nelson D.B. (1991); Conditional Heteroscedasticity in Asset Returns: A New Approach, Econometrica, 59, 347<U+2013>370.
Fernandez C., Steel M.F.J. (2000); On Bayesian Modelling of Fat Tails and Skewness, Preprint.
sged for the Student t-density.
mlsged(precip)
mlsged(precip)
Joint maximum likelihood estimation as implemented by fGarch::snormFit.
mlsnorm(x, na.rm = FALSE, ...)
mlsnorm(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Student t distribution see dsnorm.
mlsnorm
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
the parameters mean
, sd
, xi
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Fernandez C., Steel M.F.J. (2000); On Bayesian Modelling of Fat Tails and Skewness, Preprint.
dsnorm for the Student-t density.
mlsnorm(precip)
mlsnorm(precip)
Joint maximum likelihood estimation as implemented by fGarch::sstdFit.
mlsstd(x, na.rm = FALSE, ...)
mlsstd(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the skew Student t-distribution see sstd.
mlsstd
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
the parameters mean
, sd
, nu
, xi
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Fernandez C., Steel M.F.J. (2000); On Bayesian Modelling of Fat Tails and Skewness, Preprint.
sstd for the Skew Student t-density.
mlsstd(precip)
mlsstd(precip)
Joint maximum likelihood estimation as implemented by fGarch::stdFit.
mlstd(x, na.rm = FALSE, ...)
mlstd(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the Student t-distribution see std.
mlstd
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
the parameters mean
, sd
, nu
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 13. Wiley, New York.
std for the Student-t density.
mlstd(precip)
mlstd(precip)
The estimates are min(x)
and max(x)
.
mlunif(x, na.rm = FALSE, ...)
mlunif(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
currently affects nothing. |
For the density function of the logistic distribution see Uniform.
mlunif
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for min
and max
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 2, Chapter 26. Wiley, New York.
Uniform for the uniform density.
mlunif(precip)
mlunif(precip)
Uses Newton-Raphson to estimate the parameters of the Weibull distribution.
mlweibull(x, na.rm = FALSE, ...)
mlweibull(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
|
For the density function of the Weibull distribution see Weibull.
mlweibull
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
shape
and scale
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 21. Wiley, New York.
Weibull for the Weibull density.
BIC(mlweibull(precip))
BIC(mlweibull(precip))
For the density function of the zeero-inflated Poisson distribution see Zero-inflated Poisson distribution.
mlzip(x, na.rm = FALSE, ...)
mlzip(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
Not currently in use. |
mlzip
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
lambda
and pi
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kemp, A. W., & Kotz, S. (2005). Univariate Discrete Distributions (3rd ed.). Wiley-Blackwell.
Zero-inflated Poisson distribution for the density.
mlzip(corbet)
mlzip(corbet)
For the density function of the Zipf distribution see Zipf.
mlzipf(x, na.rm = FALSE, ...)
mlzipf(x, na.rm = FALSE, ...)
x |
a (non-empty) numeric vector of data values. |
na.rm |
logical. Should missing values be removed? |
... |
Not currently in use. |
This function follows the same format as every other function in the package, but most applications of Zipf's law use rank-abundance data. See, e.g., sads::fitzipf for estimation of this sort of data.
mlzipf
returns an object of class univariateML
.
This is a named numeric vector with maximum likelihood estimates for
N
and s
and the following attributes:
model |
The name of the model. |
density |
The density associated with the estimates. |
logLik |
The loglikelihood at the maximum. |
support |
The support of the density. |
n |
The number of observations. |
call |
The call as captured my |
Johnson, N. L., Kemp, A. W., & Kotz, S. (2005). Univariate Discrete Distributions (3rd ed.). Wiley-Blackwell.
Zipf for the density.
AIC(mlzipf(corbet)) # 2729.536 AIC(mllgser(corbet)) # 2835.883
AIC(mlzipf(corbet)) # 2729.536 AIC(mllgser(corbet)) # 2835.883
Selects the best model by log-likelihood, aic, or bic.
model_select( x, models = univariateML_models, criterion = c("AIC", "BIC", "logLik"), na.rm = FALSE, type = c("both", "discrete", "continuous"), return = c("best", "all"), ... )
model_select( x, models = univariateML_models, criterion = c("AIC", "BIC", "logLik"), na.rm = FALSE, type = c("both", "discrete", "continuous"), return = c("best", "all"), ... )
x |
a (non-empty) numeric vector of data values. |
models |
a character vector containing the distribution models to
select from; see |
criterion |
the model selection criterion. Must be one of |
na.rm |
logical. Should missing values be removed? |
type |
Either |
return |
character length 1. "univariateML" (default) if the function should return the single best model; "all" if a tibble data frame of all results should be returned, sorted by decreasing model performance. |
... |
unused. |
The return value depends on the return
argument.
For return = "best"
(default), model_select
returns
an object of class univariateML
For return = "all"
, model_select
returns a tibble data frame
with the following columns:
model |
The name of the model. |
\verb{d_loglik , d_aic , d_bic}
|
See |
p |
Number of parameters fitted. |
\verb{loglik , aic , bic}
|
The negative log-likelihood at the maximum,
the aic, and the bic, respectively. The minimum of each of these is noted
and then subtracted from each value to give their delta versions
|
. So, the model with the lowest aic will
have d_aic
of 0; the d_aic
of all the other models shows how much higher
their aics are from the minimum. The same goes with d_loglik
and d_bic
.
ml |
The internal code name for the model. |
univariateML |
The |
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, Volume 1, Chapter 17. Wiley, New York.
# Select among all possible continuous models. model_select(precip, type = "continuous") # View possible models to fit. print(univariateML_models) # Try out only gamma, Weibull, and exponential. model_select(precip, c("gamma", "weibull", "exp")) # Fit the discrete `corbet` data to all available discrete models model_select(corbet, type = "discrete", return = "all")
# Select among all possible continuous models. model_select(precip, type = "continuous") # View possible models to fit. print(univariateML_models) # Try out only gamma, Weibull, and exponential. model_select(precip, c("gamma", "weibull", "exp")) # Fit the discrete `corbet` data to all available discrete models model_select(corbet, type = "discrete", return = "all")
The plot
, lines
, and points
methods for
univariateML
objects.
## S3 method for class 'univariateML' plot(x, range = NULL, kind = c("d", "p", "q"), ...) ## S3 method for class 'univariateML' lines(x, range = NULL, kind = c("d", "p", "q"), ...) ## S3 method for class 'univariateML' points(x, range = NULL, kind = c("d", "p", "q"), ...)
## S3 method for class 'univariateML' plot(x, range = NULL, kind = c("d", "p", "q"), ...) ## S3 method for class 'univariateML' lines(x, range = NULL, kind = c("d", "p", "q"), ...) ## S3 method for class 'univariateML' points(x, range = NULL, kind = c("d", "p", "q"), ...)
x |
a |
range |
range of |
kind |
can be |
... |
parameters passed to |
An invisible copy of x
.
plot(mlweibull(datasets::precip), main = "Annual Precipitation in US Cities") lines(mlgamma(datasets::precip), lty = 2) rug(datasets::precip)
plot(mlweibull(datasets::precip), main = "Annual Precipitation in US Cities") lines(mlgamma(datasets::precip), lty = 2) rug(datasets::precip)
Make quantile-quantile plots and probability-probability plots using maximum likelihood estimation.
ppmlplot(y, obj, plot.it = TRUE, datax = FALSE, ...) ppmlline(...) ppmlpoints(y, obj, plot.it = TRUE, datax = TRUE, ...) qqmlplot(y, obj, plot.it = TRUE, datax = FALSE, ...) qqmlline(y, obj, datax = FALSE, probs = c(0.25, 0.75), qtype = 7, ...) qqmlpoints(y, obj, plot.it = TRUE, datax = TRUE, ...)
ppmlplot(y, obj, plot.it = TRUE, datax = FALSE, ...) ppmlline(...) ppmlpoints(y, obj, plot.it = TRUE, datax = TRUE, ...) qqmlplot(y, obj, plot.it = TRUE, datax = FALSE, ...) qqmlline(y, obj, datax = FALSE, probs = c(0.25, 0.75), qtype = 7, ...) qqmlpoints(y, obj, plot.it = TRUE, datax = TRUE, ...)
y |
Numeric vector; The data to plot on the |
obj |
Either an |
plot.it |
Logical; should the result be plotted? |
datax |
Logical; should |
... |
Graphical parameters. |
probs |
Numeric vector of length two, representing probabilities. Corresponding quantile pairs define the line drawn. |
qtype |
The |
qqmlplot
produces a quantile-quantile plot (Q-Q plot) of the values in
y
with respect to the distribution defined by obj
, which is
either a univariateML
object or a function returning a
univariateML
object when called with y
. qqmlline
adds a
line to a <U+201C>theoretical<U+201D>, quantile-quantile plot which passes through
the probs
quantiles, by default the first and third quartiles.
qqmlpoints
behaves like stats::points
and adds a Q-Q plot to
an existing plot.
ppmlplot
, ppmlline
, and ppmlpoints
produce
probability-probability plots (or P-P plots). They behave similarly to the
quantile-quantile plot functions.
This function is modeled after qqnorm.
Quantile-quantile plots and probability-probability plots are only supported for continuous distributions.
Graphical parameters may be given as arguments to all the functions below.
For qqmlplot
, qqmlpoints
, ppmlplot
, and
ppmlpoints
, a list with components x
(plotted on the x axis)
and y
(plotted on the y axis). qqmlline
and ppmlline
returns nothing.
M. B. Wilk, R. Gnadadesikan, Probability plotting methods for the analysis for the analysis of data, Biometrika, Volume 55, Issue 1, March 1968, Pages 1<U+2013>17, https://doi.org/10.1093/biomet/55.1.1
## Make a single probability plot with a line. obj <- mlgamma(Nile) qqmlplot(Nile, obj) qqmlline(Nile, obj) ## Make multiple probability plots. datax = TRUE must be used to make this ## look good. ppmlplot(airquality$Wind, mlgamma, main = "Many P-P plots") ppmlpoints(airquality$Wind, mlexp, col = "red") ppmlpoints(airquality$Wind, mlweibull, col = "purple") ppmlpoints(airquality$Wind, mllnorm, col = "blue")
## Make a single probability plot with a line. obj <- mlgamma(Nile) qqmlplot(Nile, obj) qqmlline(Nile, obj) ## Make multiple probability plots. datax = TRUE must be used to make this ## look good. ppmlplot(airquality$Wind, mlgamma, main = "Many P-P plots") ppmlpoints(airquality$Wind, mlexp, col = "red") ppmlpoints(airquality$Wind, mlweibull, col = "purple") ppmlpoints(airquality$Wind, mllnorm, col = "blue")
univariateML
object.Construct univariateML
object.
univariateML_construct(estimates, name, params)
univariateML_construct(estimates, name, params)
estimates |
The estimated parameters |
name |
Name of the |
params |
List of |
Object of class univariateML
Vector of all supported models in univariateML
.
univariateML_models
univariateML_models
An object of class character
of length 36.
The currently supported models are mlbeta, mlbetapr, mlbinom, mlcauchy, mlexp, mlgamma, mlged, mlgeom, mlgumbel, mlinvgamma, mlinvgauss, mlinvweibull, mlkumar, mllaplace, mllgamma, mllgser, mlllogis, mllnorm, mllogis, mllogitnorm, mllomax, mlnaka, mlnbinom, mlnorm, mlpareto, mlpois, mlpower, mlrayleigh, mlsged, mlsnorm, mlsstd, mlstd, mlunif, mlweibull, mlzip, mlzipf