Package 'DiscreteInverseWeibull'

Title: Discrete Inverse Weibull Distribution
Description: Probability mass function, distribution function, quantile function, random generation and parameter estimation for the discrete inverse Weibull distribution.
Authors: Alessandro Barbiero, Riccardo Inchingolo, Mario Samigli
Maintainer: Alessandro Barbiero <[email protected]>
License: GPL
Version: 1.0.2
Built: 2024-11-20 06:22:50 UTC
Source: CRAN

Help Index


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 <[email protected]>, Riccardo Inchingolo <[email protected]>, Mario Samigli <[email protected]>

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


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 qq parameter

beta

the value of the β\beta parameter

Details

The alternative hazard rate function is defined as h(x)=log(P(X>x1)/P(X>x))=log[(1q(x1)β)/(1qxβ)]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

hrdiweibull

Examples

q<-0.5
beta<-2
x<-1:10
y<-ahrdiweibull(x, q, beta)
y
plot(x,y,ylab="alt.hazard rate")

The discrete inverse Weibull distribution

Description

Probability mass function, distribution function, quantile function and random generation for the discrete inverse Weibull distribution with parameters qq 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, qq

beta

the value of the second parameter, β\beta

n

the sample size

Details

The discrete inverse Weibull distribution has probability mass function given by P(X=x;q,β)=q(x)βq(x1)βP(X=x;q,\beta)=q^{(x)^{-\beta}}-q^{(x-1)^{\beta}}, x=1,2,3,x=1,2,3,\ldots, 0<q<1,β>00<q<1, \beta>0. Its cumulative distribution function is F(x;q,β)=qxβ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 qq parameter

beta

the value of the β\beta parameter

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,β)=x=0+1F(x;q,β)E(X;q,\beta)=\sum_{x=0}^{+\infty} 1-F(x;q, \beta) and E(X2;q,β)=2x=1+x(1F(x;q,β))+E(X;q,β)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;F1(1eps;q,β))\min(nmax;F^{-1}(1-eps;q,\beta)), where F1F^{-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)

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: "P" method of proportion, "M" method of moments, "H" heuristic-maximum likelihood method, "PP" graphical method-probability plot

control

a list of additional parameters: eps, nmax for the method of moments; beta1, z, r, Leps for the heuristic method

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 2\leq 2. The method of moments cannot be applied for estimating β\beta if all the sample values are 2\leq 2; besides, it may return unreliable results since the first and second moments can be computed only if β>2\beta>2. The heuristic method cannot be applied for estimating β\beta if all the sample values are 2\leq 2.

Value

a vector containing the two estimates of qq and β\beta

See Also

heuristic, Ediweibull

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 β\beta parameter

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 qq 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

estdiweibull

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 qq parameter

beta

the value of the β\beta parameter

Details

The hazard rate function is defined as r(x)=P(X=x)/P(Xx)=(qxβq(x1)β)/(1q(x1)β)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

ahrdiweibull

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 qq parameter

beta

the value of the β\beta parameter

Value

the value of the log-likelihood function (changed in sign) of the discrete inverse Weibull distribution with parameters qq and β\beta computed on a sample x

See Also

heuristic

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 (qq and β\beta)

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,β)=(E(X;q,β)m1)2+(E(X2;q,β)m2)2L(x; q, \beta)=(E(X; q, \beta)-m_1)^2+(E(X^2; q, \beta)-m_2)^2 where m1m_1 and m2m_2 are the first and second order sample moments.

See Also

Ediweibull

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...)