Type: | Package |
Title: | Discrete Inverse Weibull Distribution |
Version: | 1.0.2 |
Date: | 2016-04-29 |
Author: | Alessandro Barbiero, Riccardo Inchingolo, Mario Samigli |
Maintainer: | Alessandro Barbiero <alessandro.barbiero@unimi.it> |
Description: | Probability mass function, distribution function, quantile function, random generation and parameter estimation for the discrete inverse Weibull distribution. |
License: | GPL-2 | GPL-3 [expanded from: GPL] |
LazyLoad: | yes |
Depends: | Rsolnp |
Packaged: | 2016-04-30 07:58:00 UTC; Barbiero |
Repository: | CRAN |
Date/Publication: | 2016-05-01 00:44:40 |
NeedsCompilation: | no |
Discrete Inverse Weibull Distribution
Description
Probability mass function, distribution function, quantile function, random generation and parameter estimation for the discrete inverse Weibull distribution
Details
Package: | DiscreteInverseWeibull |
Type: | Package |
Version: | 1.0.2 |
Date: | 2016-04-29 |
License: | GPL |
LazyLoad: | yes |
Depends: | Rsolnp |
Author(s)
Alessandro Barbiero <alessandro.barbiero@unimi.it>, Riccardo Inchingolo <dott.inchingolo_r@libero.it>, Mario Samigli <giulio.samigli@gmail.com>
References
Jazi M.A., Lai C.-D., Alamatsaz M.H. (2010) A discrete inverse Weibull distribution and estimation of its parameters, Statistical Methodology 7: 121-132
Khan M.S., Pasha G.R., Pasha A.H. (2008) Theoretical Analysis of Inverse Weibull Distribution, WSEAS Trabsactions on Mathematics 2(7): 30-38
Drapella A. (1993) Complementary Weibull distribution: unknown or just forgotten, Quality Reliability Engineering International 9: 383-385
Dutang, C., Goulet, V., Pigeon, M. (2008) actuar: An R package for actuarial science, Journal of Statistical Software 25(7): 1-37
The discrete inverse Weibull distribution
Description
Probability mass function, distribution function, quantile function and random generation for the discrete inverse Weibull distribution with parameters q
and \beta
Usage
ddiweibull(x, q, beta)
pdiweibull(x, q, beta)
qdiweibull(p, q, beta)
rdiweibull(n, q, beta)
Arguments
x |
a vector of quantiles |
p |
a vector of probabilities |
q |
the value of the first parameter, |
beta |
the value of the second parameter, |
n |
the sample size |
Details
The discrete inverse Weibull distribution has probability mass function given by P(X=x;q,\beta)=q^{(x)^{-\beta}}-q^{(x-1)^{\beta}}
, x=1,2,3,\ldots
, 0<q<1, \beta>0
. Its cumulative distribution function is F(x; q, \beta)=q^{x^{-\beta}}
Value
ddiweibull
gives the probability, pdiweibull
gives the distribution function, qdiweibull
gives the quantile function, and rdiweibull
generates random values. See the reference below for the continuous inverse Weibull distribution.
References
Dutang, C., Goulet, V., Pigeon, M. (2008) actuar: An R package for actuarial science, Journal of Statistical Software 25(7): 1-37
Examples
# Ex.1
x<-1:10
q<-0.6
beta<-0.8
ddiweibull(x, q, beta)
t<-qdiweibull(0.99, q, beta)
t
pdiweibull(t, q, beta)
# Ex.2
q<-0.4
beta<-1.7
n<-100
x<-rdiweibull(n, q, beta)
tabulate(x)/sum(tabulate(x))
y<-1:round(max(x))
# compare with
ddiweibull(y, q, beta)
First and second order moments
Description
First and second order moments of the discrete inverse Weibull distribution
Usage
Ediweibull(q, beta, eps = 1e-04, nmax = 1000)
Arguments
q |
the value of the |
beta |
the value of the |
eps |
error threshold for the approximated computation of the moments |
nmax |
a first maximum value of the support considered for the approximated computation of the moments |
Details
For a discrete inverse Weibull distribution we have E(X;q,\beta)=\sum_{x=0}^{+\infty} 1-F(x;q, \beta)
and E(X^2;q,\beta)=2\sum_{x=1}^{+\infty} x(1-F(x;q, \beta))+E(X;q, \beta)
.
The expected values are numerically computed considering a truncated support: integer values smaller than or equal to \min(nmax;F^{-1}(1-eps;q,\beta))
, where F^{-1}
is the inverse of the cumulative distribution function (implemented by the function qdiweibull
). Increasing the value of nmax
or decreasing the value of eps
improves the approximation, but slows down the calculation speed
Value
a list comprising the (approximate) first and second order moments of the discrete inverse Weibull distribution. Note that the first moment is finite iff \beta
is greater than 1; the second order moment is finite iff \beta
is greater than 2
References
Khan M.S., Pasha G.R., Pasha A.H. (2008) Theoretical Analysis of Inverse Weibull Distribution, WSEAS Trabsactions on Mathematics 2(7): 30-38
Examples
# Ex.1
q<-0.75
beta<-1.25
Ediweibull(q, beta)
# Ex.2
q<-0.5
beta<-2.5
Ediweibull(q, beta)
# Ex.3
q<-0.4
beta<-4
Ediweibull(q, beta)
Alternative hazard rate function
Description
Alternative hazard rate function for the discrete inverse Weibull distribution
Usage
ahrdiweibull(x, q, beta)
Arguments
x |
a vector of values |
q |
the value of the |
beta |
the value of the |
Details
The alternative hazard rate function is defined as h(x)=\log(P(X>x-1)/P(X>x))=\log[(1-q^{(x-1)^{-\beta}})/(1-q^{x^{-\beta}})]
Value
the value of the alternative hazard rate function in the x
values
See Also
Examples
q<-0.5
beta<-2
x<-1:10
y<-ahrdiweibull(x, q, beta)
y
plot(x,y,ylab="alt.hazard rate")
Estimation of parameters
Description
Sample estimation of the parameters of the discrete inverse Weibull distribution
Usage
estdiweibull(x, method="P", control=list())
Arguments
x |
a vector of sample values |
method |
the estimation method that will be carried out: |
control |
a list of additional parameters:
|
Details
For a description of the methods, have a look at the reference. Note that they may be not applicable to some specific samples. For examples, the method of proportion cannot be applied if there are no 1s in the samples; it cannot be applied for estimating \beta
if all the sample values are \leq 2
. The method of moments cannot be applied for estimating \beta
if all the sample values are \leq 2
; besides, it may return unreliable results since the first and second moments can be computed only if \beta>2
. The heuristic method cannot be applied for estimating \beta
if all the sample values are \leq 2
.
Value
a vector containing the two estimates of q
and \beta
See Also
Examples
n<-100
q<-0.5
beta<-2.5
# generation of a sample
x<-rdiweibull(n, q, beta)
# sample estimation through each of the implemented methods
estdiweibull(x, method="P")
estdiweibull(x, method="M")
estdiweibull(x, method="H")
estdiweibull(x, method="PP")
Heuristic method of estimation
Description
Heuristic method for the estimation of parameters of the discrete inverse Weibull
Usage
heuristic(x, beta1=1, z = 0.1, r = 0.1, Leps = 0.01)
Arguments
x |
a vector of sample values |
beta1 |
launch value of the |
z |
initial value of width |
r |
initial value of rate |
Leps |
tolerance error for the likelihood function |
Details
For a detailed description of the method, have a look at the reference
Value
a list containig the two estimates of q
and \beta
References
Jazi M.A., Lai C.-D., Alamatsaz M.H. (2010) A discrete inverse Weibull distribution and estimation of its parameters, Statistical Methodology, 7: 121-132
Drapella A. (1993) Complementary Weibull distribution: unknown or just forgotten, Quality Reliability Engineering International 9: 383-385
See Also
Examples
n<-50
q<-0.25
beta<-1.5
x<-rdiweibull(n, q, beta)
# estimates using the heuristic algorithm
par0<-heuristic(x)
par0
# change the default values of some working parameters...
par1<-heuristic(x, beta1=2)
par1
par2<-heuristic(x, z=0.5)
par2
par3<-heuristic(x, r=0.2)
par3
par4<-heuristic(x, Leps=0.1)
par4
# ...there should be just light differences among the estimates...
# ... and among the corresponding values of the loglikelihood functions
loglikediw(x, par0[1], par0[2])
loglikediw(x, par1[1], par1[2])
loglikediw(x, par2[1], par2[2])
loglikediw(x, par3[1], par3[2])
loglikediw(x, par4[1], par4[2])
Hazard rate function
Description
Hazard rate function for the discrete inverse Weibull distribution
Usage
hrdiweibull(x, q, beta)
Arguments
x |
a vector of values |
q |
the value of the |
beta |
the value of the |
Details
The hazard rate function is defined as r(x)=P(X=x)/P(X\ge x)=(q^{x^{-\beta}}-q^{(x-1)^{-\beta}})/(1-q^{(x-1)^{-\beta}})
Value
the hazard rate function computed on the x
values
See Also
Examples
q<-0.5
beta<-2.5
x<-1:10
hrdiweibull(x, q, beta)
likelihood function
Description
Log-likelihood function of the discrete inverse Weibull
Usage
loglikediw(x, q, beta)
Arguments
x |
a vector of sample values |
q |
the value of the |
beta |
the value of the |
Value
the value of the log-likelihood function (changed in sign) of the discrete inverse Weibull distribution with parameters q
and \beta
computed on a sample x
See Also
Examples
n<-100
q<-0.4
beta<-2
x<-rdiweibull(n, q, beta)
# loglikelihood function (changed in sign) computed on the true values
loglikediw(x, q, beta)
par<-estdiweibull(x, method="H")
par
# loglikelihood function (changed in sign) computed on the ML estimates
loglikediw(x, par[1], par[2])
# it should be smaller than before...
Loss function
Description
Quadratic loss function for the method of moments
Usage
lossdiw(x, par, eps = 1e-04, nmax=1000)
Arguments
x |
a vector of sample values |
par |
a vector of parameters ( |
eps |
a tolerance error for the computation of first order moments |
nmax |
a first maximum value for the computation of first order moments |
Value
the value of the quadratic loss function L(x; q, \beta)=(E(X; q, \beta)-m_1)^2+(E(X^2; q, \beta)-m_2)^2
where m_1
and m_2
are the first and second order sample moments.
See Also
Examples
n<-100
q<-0.5
beta<-2.5
x<-rdiweibull(n, q, beta)
# loss function computed on the true values
lossdiw(x, c(q, beta))
par<-estdiweibull(x, method="M")
# estimates of the parameters through the method of moments
par
# loss function computed on the estimates derived through
# the method of moments
lossdiw(x, par)
# it should be zero (however, smaller than before...)