mpsedist: Maximum Product of Spacing Fit of Univariate Distributions.

Description Usage Arguments Details Value Author(s) Source References See Also Examples

Description

Fit of univariate distributions for non-censored data using maximum product of spacing estimation (mpse), also called maximum spacing estimation.

Usage

1
2
3
4
mpsedist(data, distr, start = NULL, fix.arg = NULL,
  optim.method = "default", lower = -Inf, upper = Inf,
  custom.optim = NULL, weights = NULL, silent = TRUE, gradient = NULL,
  ...)

Arguments

data

A numeric vector with the observed values for non-censored data.

distr

A character string "name" naming a distribution for which the corresponding density function dname and the corresponding distribution function pname must be classically defined.

start

A named list giving the initial values of parameters of the named distribution or a function of data computing initial values and returning a named list. This argument may be omitted (default) for some distributions for which reasonable starting values are computed (see the 'details' section of mledist).

fix.arg

An optional named list giving the values of fixed parameters of the named distribution or a function of data computing (fixed) parameter values and returning a named list. Parameters with fixed value are thus NOT estimated.

optim.method

"default" (see details) or an optimization method to pass to optim.

lower

Left bounds on the parameters for the "L-BFGS-B" method (see optim) or the constrOptim function (as an equivalent linear constraint).

upper

Right bounds on the parameters for the "L-BFGS-B" method (see optim) or the constrOptim function (as an equivalent linear constraint).

custom.optim

A function carrying the optimization (see details).

weights

An optional vector of weights to be used in the fitting process. Should be NULL or a numeric vector with strictly positive numbers. If non-NULL, weighted mpse is used, otherwise ordinary mpse.

silent

A logical to remove or show warnings when bootstraping.

gradient

A function to return the gradient of the optimization objective function for the "BFGS", "CG" and "L-BFGS-B" methods. If it is NULL, a finite-difference approximation will be used, see optim.

...

Further arguments passed to the optim, constrOptim or custom.optim function.

Details

The mpsedist function carries out the maximum product of spacing estimation numerically, by maximization of the arithmetic mean of \log(F(k) - F(k-1)).

The optimization process is the same as mledist, see the 'details' section of that function.

Optionally, a vector of weights can be used in the fitting process. By default (when weigths=NULL), ordinary mpse is carried out, otherwise the specified weights are used to compute a weighted arithmetic mean.

We believe this function should be added to the package fitdistrplus. Until it is accepted and incorporated into that package, it will remain in the package BMT. This function is internally called in BMTfit.mpse.

Value

mpsedist returns a list with following components,

estimate

the parameter estimates.

convergence

an integer code for the convergence of optim defined as below or defined by the user in the user-supplied optimization function.

0 indicates successful convergence.

1 indicates that the iteration limit of optim has been reached.

10 indicates degeneracy of the Nealder-Mead simplex.

100 indicates that optim encountered an internal error.

value

the value of the optimization objective function at the solution found.

loglik

the log-likelihood.

hessian

a symmetric matrix computed by optim as an estimate of the Hessian at the solution found or computed in the user-supplied optimization function.

optim.function

the name of the optimization function used.

fix.arg

the named list giving the values of parameters of the named distribution that must kept fixed rather than estimated by maximum likelihood or NULL if there are no such parameters.

optim.method

when optim is used, the name of the algorithm used, NULL otherwise.

fix.arg.fun

the function used to set the value of fix.arg or NULL.

weights

the vector of weigths used in the estimation process or NULL.

counts

A two-element integer vector giving the number of calls to the log-likelihood function and its gradient respectively. This excludes those calls needed to compute the Hessian, if requested, and any calls to log-likelihood function to compute a finite-difference approximation to the gradient. counts is returned by optim or the user-supplied optimization function, or set to NULL.

optim.message

A character string giving any additional information returned by the optimizer, or NULL. To understand exactly the message, see the source code.

Author(s)

Camilo Jose Torres-Jimenez [aut,cre] cjtorresj@unal.edu.co

Source

Based on the function mledist of the R package: fitdistrplus

Delignette-Muller ML and Dutang C (2015), fitdistrplus: An R Package for Fitting Distributions. Journal of Statistical Software, 64(4), 1-34.

Functions checkparam and start.arg.default are needed and were copied from the same package (fitdistrplus version: 1.0-9).

References

Cheng, R. and N. Amin (1983). Estimating parameters in continuous univariate distributions with a shifted origin. Journal of the Royal Statistical Society. Series B (Methodological), 394-403.

Ranneby, B. (1984). The maximum spacing method. an estimation method related to the maximum likelihood method. Scandinavian Journal of Statistics, 93-112.

See Also

mqdedist, mledist, mmedist, qmedist, mgedist, and optim.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# (1) basic fit of a normal distribution 
set.seed(1234)
x1 <- rnorm(n = 100)
mean(x1); sd(x1)
mpse1 <- mpsedist(x1, "norm")
mpse1$estimate

# (2) defining your own distribution functions, here for the Gumbel 
# distribution for other distributions, see the CRAN task view dedicated 
# to probability distributions
dgumbel <- function(x, a, b) 1/b*exp((a-x)/b)*exp(-exp((a-x)/b))
pgumbel <- function(q, a, b) exp(-exp((a-q)/b))
qgumbel <- function(p, a, b) a-b*log(-log(p))
mpse1 <- mpsedist(x1, "gumbel", start = list(a = 10, b = 5))
mpse1$estimate

# (3) fit a discrete distribution (Poisson)
set.seed(1234)
x2 <- rpois(n = 30, lambda = 2)
mpse2 <- mpsedist(x2, "pois")
mpse2$estimate

# (4) fit a finite-support distribution (beta)
set.seed(1234)
x3 <- rbeta(n = 100, shape1 = 5, shape2 = 10)
mpse3 <- mpsedist(x3, "beta")
mpse3$estimate

# (5) fit frequency distributions on USArrests dataset.
x4 <- USArrests$Assault
mpse4pois <- mpsedist(x4, "pois")
mpse4pois$estimate
mpse4nbinom <- mpsedist(x4, "nbinom")
mpse4nbinom$estimate

# (6) weighted fit of a normal distribution 
set.seed(1234)
w1 <- runif(101)
mpse1 <- mpsedist(x1, "norm", weights = w1)
mpse1$estimate

BMT documentation built on May 2, 2019, 5:41 a.m.

Related to mpsedist in BMT...