Description Usage Arguments Details Value Author(s) Source References See Also Examples
Fit of univariate distributions for non-censored data using maximum product of spacing estimation (mpse), also called maximum spacing estimation.
1 2 3 4 |
data |
A numeric vector with the observed values for non-censored data. |
distr |
A character string |
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 |
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 |
|
lower |
Left bounds on the parameters for the |
upper |
Right bounds on the parameters for the |
custom.optim |
A function carrying the optimization (see details). |
weights |
An optional vector of weights to be used in the fitting
process. Should be |
silent |
A logical to remove or show warnings when bootstraping. |
gradient |
A function to return the gradient of the optimization
objective function for the |
... |
Further arguments passed to the |
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
.
mpsedist
returns a list with following components,
estimate |
the parameter estimates. |
convergence |
an integer code for the convergence of
|
value |
the value of the optimization objective function at the solution found. |
loglik |
the log-likelihood. |
hessian |
a symmetric matrix computed by |
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 |
optim.method |
when |
fix.arg.fun |
the function used to set the value of |
weights |
the vector of weigths used in the estimation process or
|
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. |
optim.message |
A character string giving any additional information
returned by the optimizer, or |
Camilo Jose Torres-Jimenez [aut,cre] cjtorresj@unal.edu.co
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).
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.
mqdedist
, mledist
,
mmedist
, qmedist
,
mgedist
, and optim
.
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.