Last data update: 2014.03.03
R: Two-Parameter Lindley Distribution
Two-Parameter Lindley Distribution
Description
Density function, distribution function, quantile function, random number generation and hazard rate function for the two-parameter Lindley distribution with parameters theta and alpha.
Usage
dslindley(x, theta, alpha, log = FALSE)
pslindley(q, theta, alpha, lower.tail = TRUE, log.p = FALSE)
qslindley(p, theta, alpha, lower.tail = TRUE, log.p = FALSE)
rslindley(n, theta, alpha, mixture = TRUE)
hslindley(x, theta, alpha, log = FALSE)
Arguments
x, q
vector of positive quantiles.
theta
positive parameter.
alpha
greater than -theta.
log, log.p
logical; If TRUE, probabilities p are given as log(p).
lower.tail
logical; If TRUE, (default), P(X ≤q x) are returned, otherwise P(X > x) .
p
vector of probabilities.
n
number of observations. If length(n) > 1
, the length is taken to be the number required.
mixture
logical; If TRUE, (default), random deviates are generated from a two-component mixture of gamma distributions, otherwise from the quantile function.
Details
Probability density function
f(xmid θ,α )=frac{{θ }^{2}}{θ +α }≤ft(1+α x
ight) e^{-θ x}
Cumulative distribution function
F(xmid θ,α )=1-frac{≤ft( θ + α +α θ x
ight) }{θ +α }e^{-θ x}
Quantile function
Q(pmid θ,α )=-frac{1}{θ }-frac{1}{α }-frac{1}{θ }W_{-1}≤ft( frac{1}{α }(p-1)≤ft( θ +α
ight)e^{-{frac{α +θ }{α }}}
ight)
Hazard rate function
h(xmid θ )=frac{θ ^{2}}{≤ft( θ + α +αθ x
ight) }(1+α x)
where θ > 0 , α > -θ and W_{-1} denotes the negative branch of the Lambert W function.
Particular case: α = 1 the one-parameter Lindley distribution.
Value
dslindley
gives the density, pslindley
gives the distribution function, qslindley
gives the quantile function, rslindley
generates random deviates and hslindley
gives the hazard rate function.
Invalid arguments will return an error message.
Author(s)
Josmar Mazucheli jmazucheli@gmail.com
Larissa B. Fernandes lbf.estatistica@gmail.com
Source
[d-h-p-q-r]slindley are calculated directly from the definitions. rslindley
uses either a two-component mixture of the gamma distributions or the quantile function.
References
Shanker, R., Sharma, S. and Shanker, R. (2013). A two-parameter Lindley distribution for modeling waiting and survival times data. Applied Mathematics , 4 , (2), 363-368.
See Also
lambertWm1
.
Examples
set.seed(1)
x <- rslindley(n = 1000, theta = 1.5, alpha = 1.5, mixture = TRUE)
R <- range(x)
S <- seq(from = R[1], to = R[2], by = 0.1)
plot(S, dslindley(S, theta = 1.5, alpha = 1.5), xlab = 'x', ylab = 'pdf')
hist(x, prob = TRUE, main = '', add = TRUE)
p <- seq(from = 0.1, to = 0.9, by = 0.1)
q <- quantile(x, prob = p)
pslindley(q, theta = 1.5, alpha = 1.5, lower.tail = TRUE)
pslindley(q, theta = 1.5, alpha = 1.5, lower.tail = FALSE)
qslindley(p, theta = 1.5, alpha = 1.5, lower.tail = TRUE)
qslindley(p, theta = 1.5, alpha = 1.5, lower.tail = FALSE)
library(fitdistrplus)
fit <- fitdist(x, 'slindley', start = list(theta = 1.5, alpha = 1.5))
plot(fit)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(LindleyR)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LindleyR/SLindley.Rd_%03d_medium.png", width=480, height=480)
> ### Name: SLindley
> ### Title: Two-Parameter Lindley Distribution
> ### Aliases: SLindley dslindley hslindley pslindley qslindley rslindley
>
> ### ** Examples
>
> set.seed(1)
> x <- rslindley(n = 1000, theta = 1.5, alpha = 1.5, mixture = TRUE)
> R <- range(x)
> S <- seq(from = R[1], to = R[2], by = 0.1)
> plot(S, dslindley(S, theta = 1.5, alpha = 1.5), xlab = 'x', ylab = 'pdf')
> hist(x, prob = TRUE, main = '', add = TRUE)
>
> p <- seq(from = 0.1, to = 0.9, by = 0.1)
> q <- quantile(x, prob = p)
> pslindley(q, theta = 1.5, alpha = 1.5, lower.tail = TRUE)
10% 20% 30% 40% 50% 60% 70%
0.09043296 0.19088344 0.30270821 0.42976697 0.53676494 0.63408868 0.72294231
80% 90%
0.81556379 0.90557371
> pslindley(q, theta = 1.5, alpha = 1.5, lower.tail = FALSE)
10% 20% 30% 40% 50% 60% 70%
0.90956704 0.80911656 0.69729179 0.57023303 0.46323506 0.36591132 0.27705769
80% 90%
0.18443621 0.09442629
> qslindley(p, theta = 1.5, alpha = 1.5, lower.tail = TRUE)
[1] 0.1341529 0.2729038 0.4205503 0.5820360 0.7641288 0.9774690 1.2413431
[8] 1.5981840 2.1812080
> qslindley(p, theta = 1.5, alpha = 1.5, lower.tail = FALSE)
[1] 2.1812080 1.5981840 1.2413431 0.9774690 0.7641288 0.5820360 0.4205503
[8] 0.2729038 0.1341529
>
> library(fitdistrplus)
Loading required package: MASS
> fit <- fitdist(x, 'slindley', start = list(theta = 1.5, alpha = 1.5))
> plot(fit)
>
>
>
>
>
>
> dev.off()
null device
1
>