Weib {joker}R Documentation

Weibull Distribution

Description

The Weibull distribution is an absolute continuous probability distribution, parameterized by a shape parameter k > 0 and a scale parameter \lambda > 0.

Usage

Weib(shape = 1, scale = 1)

## S4 method for signature 'Weib,numeric'
d(distr, x, log = FALSE)

## S4 method for signature 'Weib,numeric'
p(distr, q, lower.tail = TRUE, log.p = FALSE)

## S4 method for signature 'Weib,numeric'
qn(distr, p, lower.tail = TRUE, log.p = FALSE)

## S4 method for signature 'Weib,numeric'
r(distr, n)

## S4 method for signature 'Weib'
mean(x)

## S4 method for signature 'Weib'
median(x)

## S4 method for signature 'Weib'
mode(x)

## S4 method for signature 'Weib'
var(x)

## S4 method for signature 'Weib'
sd(x)

## S4 method for signature 'Weib'
skew(x)

## S4 method for signature 'Weib'
kurt(x)

## S4 method for signature 'Weib'
entro(x)

llweibull(x, shape, scale)

## S4 method for signature 'Weib,numeric'
ll(distr, x)

eweibull(x, type = "mle", ...)

## S4 method for signature 'Weib,numeric'
mle(
  distr,
  x,
  par0 = "lme",
  method = "L-BFGS-B",
  lower = 1e-05,
  upper = Inf,
  na.rm = FALSE
)

## S4 method for signature 'Weib,numeric'
me(distr, x, par0 = "lme", lower = 0.5, upper = Inf, na.rm = FALSE)

Arguments

shape, scale

numeric. The non-negative distribution parameters.

distr

an object of class Weib.

x

For the density function, x is a numeric vector of quantiles. For the moments functions, x is an object of class Weib. For the log-likelihood and the estimation functions, x is the sample of observations.

log, log.p

logical. Should the logarithm of the probability be returned?

q

numeric. Vector of quantiles.

lower.tail

logical. If TRUE (default), probabilities are P(X \leq x), otherwise P(X > x).

p

numeric. Vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

type

character, case ignored. The estimator type (mle, me or lme).

...

extra arguments.

par0, method, lower, upper

arguments passed to optim for the mle and me optimization. See Details.

na.rm

logical. Should the NA values be removed?

Details

The probability density function (PDF) of the Weibull distribution is:

f(x; k, \lambda) = \frac{k}{\lambda}\left(\frac{x}{\lambda} \right)^{k - 1} \exp\left[-\left(\frac{x}{\lambda}\right)^k\right], \quad x \geq 0 .

For the parameter estimation, both the MLE and the ME cannot be explicitly derived. However, the L-moment estimator (type = "lme") is available, and is used as initialization for the numerical approximation of the MLE and the ME.

The MLE and ME of the Weibull distribution parameters is not available in closed form and has to be approximated numerically. The optimization can be performed on the shape parameter k\in(0,+\infty).

For the MLE, this is done with optim(). The default method used is the L-BFGS-B method with lower bound 1e-5 and upper bound Inf. The par0 argument can either be a numeric (satisfying ⁠lower <= par0 <= upper⁠) or a character specifying the closed-form estimator to be used as initialization for the algorithm ("lme" - the default value).

For the ME, this is done with uniroot(). Again, the par0 argument can either be a numeric (satisfying ⁠lower <= par0 <= upper⁠) or a character specifying the closed-form estimator to be used as initialization for the algorithm ("mle" or "lme" - the default value). The lower and upper bounds are set by default to 0.5 and Inf, respectively. Note that the ME equations involve the \Gamma(1 + 1 \ k), which can become unreliable for small values of k, hence the 0.5 lower bound. Specifying a lower bound below 0.5 will result in a warning and be ignored.

Value

Each type of function returns a different type of object:

References

Kim, H. M., Jang, Y. H., Arnold, B. C., & Zhao, J. (2024). New efficient estimators for the Weibull distribution. Communications in Statistics-Theory and Methods, 53(13), 4576-4601.

See Also

Functions from the stats package: dweibull(), pweibull(), qweibull(), rweibull()

Examples

# -----------------------------------------------------
# Weibull Distribution Example
# -----------------------------------------------------

# Create the distribution
a <- 3 ; b <- 5
D <- Weib(a, b)

# ------------------
# dpqr Functions
# ------------------

d(D, c(0.3, 2, 10)) # density function
p(D, c(0.3, 2, 10)) # distribution function
qn(D, c(0.4, 0.8)) # inverse distribution function
x <- r(D, 100) # random generator function

# alternative way to use the function
df <- d(D) ; df(x) # df is a function itself

# ------------------
# Moments
# ------------------

mean(D) # Expectation
median(D) # Median
mode(D) # Mode
var(D) # Variance
sd(D) # Standard Deviation
skew(D) # Skewness
kurt(D) # Excess Kurtosis
entro(D) # Entropy

# List of all available moments
mom <- moments(D)
mom$mean # expectation

# ------------------
# Point Estimation
# ------------------

ll(D, x)
llweibull(x, a, b)

eweibull(x, type = "mle")
eweibull(x, type = "me")
eweibull(x, type = "lme")

mle(D, x)
me(D, x)
e(D, x, type = "mle")

mle("weib", x) # the distr argument can be a character

[Package joker version 0.14.2 Index]