Package 'DiscreteLaplace'

Title: Discrete Laplace Distributions
Description: Probability mass function, distribution function, quantile function, random generation and estimation for the skew discrete Laplace distributions.
Authors: Alessandro Barbiero <[email protected]>, Riccardo Inchingolo <[email protected]>
Maintainer: Alessandro Barbiero <[email protected]>
License: GPL
Version: 1.1.1
Built: 2024-12-16 06:45:33 UTC
Source: CRAN

Help Index


Discrete Laplace Distributions

Description

Probability mass function, distribution function, quantile function, random generation and sample estimation for two discrete skew Laplace distributions on integers. The skew discrete Laplace distributions here considered are that proposed by Kozubowski and Inusah (2006), henceforth referred to as DSL, and the alternative one proposed by Barbiero (2014), henceforth ADSL.

Details

Package: DiscreteLaplace
Type: Package
Version: 1.1.1
Date: 2016-04-29
License: GPL
LazyLoad: yes

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

Maintainer: Alessandro Barbiero <[email protected]>

References

T. J. Kozubowski, S. Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571, http://dx.doi.org/10.1007/s10463-005-0029-1

A. Barbiero (2014) An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67, http://dx.doi.org/10.1016/j.stamet.2013.07.002


Probability mass function, cumulative distribution function, quantile function and random generation of the DSL

Description

The function computes the probability mass function, the cumulative distribution function, the quantile function of the DSL and implements random generation.

Usage

ddlaplace(x, p, q)
pdlaplace(x, p, q)
qdlaplace(prob, p, q)
rdlaplace(n, p, q)

Arguments

x

vector of quantiles

p

the first parameter pp in (0,1)(0,1) of the SDL

q

the second parameter qq in (0,1)(0,1) of the SDL

prob

vector of probabilities

n

number of observations

Details

The pmf of the SDL is given by

P(X=x;p,q)=(1p)(1q)1pqpx;x=0,1,2,3,P(X=x; p, q)=\frac{(1-p)(1-q)}{1-pq}p^x; x=0,1,2,3,\dots

P(X=x;p,q)=(1p)(1q)1pqqx;x=0,1,2,3,P(X=x; p, q)=\frac{(1-p)(1-q)}{1-pq}q^{|x|}; x=0,-1,-2,-3,\dots

whereas the cumulative distribution function is given by

F(x;p,q)=P(Xx)=(1p)qx1pq,x<0F(x; p, q)=P(X\leq x)=\frac{(1-p)q^{-\lfloor x\rfloor}}{1-pq},x<0

F(x;p,q)=P(Xx)=1(1q)px+11pq,x0F(x; p, q)=P(X\leq x)=1-\frac{(1-q)p^{\lfloor x\rfloor+1}}{1-pq},x\geq 0

Value

ddlaplace returns the probability of x; pdlaplace returns the cumulate probability of x; qdlaplace returns the prob- quantile; rdlaplace returns a random sample of size n from DSL.

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

Tomasz J. Kozubowski, Seidu Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571

See Also

ddlaplace2

Examples

# pmf
p<-0.7
q<-0.45
x<--10:10
prob<-ddlaplace(x, p, q)
plot(x, prob, type="h")
prob<-ddlaplace(x, q, p) # swap the parameters
plot(x, prob, type="h")
ddlaplace(-4:4, 1:9/10, 9:1/10) # letting p and q be vectors
# cdf
p<-0.2
q<-0.5
x<-c(-3, -1, pi)
pdlaplace(x, p, q)
# quantile function
p<-0.8
q<-0.4
prob<-c(0.2,0.5,0.8)
x<-qdlaplace(prob, p, q)
x # check
upper<-pdlaplace(x, p, q)
upper
lower<-pdlaplace(x-1, p, q)
lower
lower<=prob & prob<=upper
# random generation
n<-100
p<-0.3
q<-0.5
x<-rdlaplace(n, p, q)
x
t<-table(x)
t
plot(t)

Probability mass function of the ADSL

Description

The function computes the probability mass function, the cumulative distribution function, the quantile function of the ADSL and provides random generation of samples from the same model

Usage

ddlaplace2(x, p, q)
palaplace2(x, p, q)
pdlaplace2(x, p, q)
qdlaplace2(prob, p, q)
rdlaplace2(n, p, q)

Arguments

x

vector of quantiles

p

the first parameter pp in (0,1)(0,1) of the ADSL

q

the second parameter qq in (0,1)(0,1) of the ADSL

prob

vector of probabilities

n

number of observations

Details

The probability mass funtion of the ADSL distribution is given by:

P(X=x;p,q)=logplog(pq)q(x+1)(1q)P(X=x;p,q)=\frac{\log p}{\log (pq)}q^{-(x+1)}(1-q) for x=,2,1x=\dots, -2, -1

and

P(X=x;p,q)=logqlog(pq)px(1p)P(X=x;p,q)=\frac{\log q}{\log (pq)}p^{x}(1-p) for x=0,1,2,x=0, 1, 2, \dots

Its cumulative distribution function is:

F(x;p,q)=logplog(pq)q(x+1)F(x;p,q)=\frac{\log p}{\log (pq)}q^{-(\lfloor x \rfloor+1)} for x<0x<0

and

F(x;p,q)=1logqlog(pq)p(x+1)F(x;p,q)=1-\frac{\log q}{\log (pq)}p^{(\lfloor x \rfloor+1)} for x0x\geq 0

Value

ddlaplace2 returns the probability of x; pdlaplace2 returns the cumulate probability of x; qdlaplace2 returns the prob- quantile; rdlaplace2 returns a random sample of size n from ADSL.

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67

See Also

ddlaplace

Examples

# pmf
p <- 0.7
q <- 0.45
x <- -10:10
prob <- ddlaplace2(x, p, q)
plot(x, prob, type="h")
# swap the parameters
prob <- ddlaplace2(x, q, p)
plot(x, prob, type="h")
# letting p and q be vectors...
ddlaplace2(-4:4, 1:9/10, 9:1/10)
# cdf
pdlaplace2(x, p, q)
pdlaplace2(pi, p, q)
pdlaplace2(floor(pi), p, q)
# quantile function
qdlaplace(1:9/10, p, q)
# random generation
y <- rdlaplace2(n=1000, p, q)
plot(table(y))

Log-likelihood function for the ADSL distribution

Description

Log-likelihood function (changed in sign) for the ADSL distribution.

Usage

dlaplacelike2(par, x)

Arguments

par

the vector of parameters (p,q)(p,q)

x

a vector of observations from ADSL

Value

The log-likelihood function with changed sign.

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67

See Also

estdlaplace2, ddlaplace2

Examples

p <- 0.25
q <- 0.7
x <- rdlaplace2(n=100, p, q)
par <- estdlaplace2(x, "ML")
-dlaplacelike2(par, x) # greater than...
-dlaplacelike2(c(p, q), x)

Moments of the discrete Laplace distribution

Description

The function provides the expected value and the variance of the SDL, and the expectation of its absolute value.

Usage

Edlaplace(p, q)

Arguments

p

the first parameter, in (0,1)(0,1), of the DSL

q

the second parameter, in (0,1)(0,1), of the DSL

Details

E(X;p,q)=11p11q=p1pq1qE(X;p,q)=\frac{1}{1-p}-\frac{1}{1-q}=\frac{p}{1-p}-\frac{q}{1-q},

E(X;p,q)=q(1p)2+p(1q)2(1qp)(1q)(1p)E(|X|;p,q)=\frac{q(1-p)^2+p(1-q)^2}{(1-qp)(1-q)(1-p)},

V(X;p,q)=1(1p)2(1q)2[q(1p)3(1+q)+p(1q)3(1+p)1pq(pq)2]V(X;p,q)=\frac{1}{(1-p)^2(1-q)^2}[\frac{q(1-p)^3(1+q)+p(1-q)^3(1+p)}{1-pq}-(p-q)^2]

Value

A list of three items:

E1

expected value

E1a

expectation of the absolute value

V

variance

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

T. J. Kozubowski, S. Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571

See Also

ddlaplace

Examples

# ex.1
p<-0.5
q<-0.4
Edlaplace(p, q)
# ex.2
p<-0.1
q<-0.9
Edlaplace(p, q)

First- and second-order moments of ADSL

Description

First- and second-order moment of the ADSL distribution.

Usage

Edlaplace2(p, q)

Arguments

p

the first parameter pp, in (0,1)(0,1), of the ADSL

q

the first parameter qq, in (0,1)(0,1), of the ADSL

Details

For the ADSL distribution,

E(X;p,q)=logqlog(pq)p1plogplog(pq)11qE(X;p,q)=\frac{\log q}{\log(pq)}\frac{p}{1-p}-\frac{\log p}{\log(pq)}\frac{1}{1-q}

and

E(X2;p,q)=logqlog(pq)p(1+p)(1p)2+logplog(pq)1+q(1q)2E(X^2;p,q)=\frac{\log q}{\log(pq)}\frac{p(1+p)}{(1-p)^2}+\frac{\log p}{\log(pq)}\frac{1+q}{(1-q)^2}

Value

A list containing the first- and the second-order moments of the ADSL distribution, E1 and E2.

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67

See Also

estdlaplace2, loss, ddlaplace2

Examples

Edlaplace2(p=0.3, q=0.3)
Edlaplace2(p=0.3, q=0.6)
Edlaplace2(p=0.6, q=0.3)
Edlaplace2(p=0.6, q=0.6)

Sample estimation for the DSL

Description

The function provides the maximum likelihood estimates for the parameters of the DSL and the estimate of the inverse of the Fisher information matrix. The method of moments estimates of pp and qq coincide with the maximum likelihood estimates.

Usage

estdlaplace(x)

Arguments

x

a vector of observations from the DSL

Details

See the reference. If xˉ+=1ni=1nxi+\bar{x}^{+}=\frac{1}{n}\sum_{i=1}^n x_i^{+}, xˉ=1ni=1nxi\bar{x}^{-}=\frac{1}{n}\sum_{i=1}^n x_i^{-} where x+x^{+} and xx^{-} are the positive and the negative parts of xx, respectively: x+=xx^{+}=x if x0x\geq 0 and zero otherwise, x=(x)+x^{-}=(-x)^{+}, then

q^=2xˉ(1+xˉ)1+2xˉxˉ+1+4xˉxˉ+\hat{q}=\frac{2\bar{x}^{-}(1+\bar{x})}{1+2\bar{x}^{-}\bar{x}+\sqrt{1+4\bar{x}^{-}\bar{x}^{+}}}, p^=q^+xˉ(1q^)1+xˉ(1q^)\hat{p}=\frac{\hat{q}+\bar{x}(1-\hat{q})}{1+\bar{x}(1-\hat{q})}

when xˉ0\bar{x}\geq 0 and

p^=2xˉ+(1xˉ)12xˉ+xˉ+1+4xˉxˉ+\hat{p}=\frac{2\bar{x}^{+}(1-\bar{x})}{1-2\bar{x}^{+}\bar{x}+\sqrt{1+4\bar{x}^{-}\bar{x}^{+}}}, q^=p^xˉ(1p^)1xˉ(1p^)\hat{q}=\frac{\hat{p}-\bar{x}(1-\hat{p})}{1-\bar{x}(1-\hat{p})}

when xˉ0\bar{x}\leq 0.

Value

A list comprising

hatp

estimate of pp

hatq

estimate of qq

hatSigma

estimate of the inverse of the Fisher information matrix

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

T. J. Kozubowski, S. Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571

See Also

ddlaplace

Examples

p<-0.6
q<-0.3
n<-20
x<-rdlaplace(n, p, q)
est<-estdlaplace(x)
est[1]
est[2]
est[3]
# increase n
n<-100
x<-rdlaplace(n, p, q)
est<-estdlaplace(x)
est[1]
est[2]
est[3]
# swap the parameters
x<-rdlaplace(n, q, p)
est<-estdlaplace(x)
est[1]
est[2]
est[3]

Sample estimation for the ADSL

Description

The function provides the point estimates for the parameters of the ASDL, resorting to four possible methods: method of moments, maximum likelihood method, method of proportion, modified method of moments. For details, please take a look at the references.

Usage

estdlaplace2(x, method = "M", err = 0.001, parml = c(exp(-1), exp(-1)))

Arguments

x

a vector of observations from the ADSL

method

M for the method of moments, ML for the maximum likelihood methods, P for the method of proportion, MM for the modified method of moments

err

a positive tolerance value, as small as possible, used in the definition of lower and upper bounds of the parameters pp and qq in the minimization algorithm utilized by the method of moments

parml

starting values for pp and qq in the optimization process for the maximum likelihood method

Value

a vector with the parameter estimates of pp and qq.

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67

See Also

dlaplacelike2

Examples

p <- 0.4
q <- 0.6
x <- rdlaplace2(n=100, p, q)
est <- matrix(0, 5, 2)
est[1,] <- c(p,q)
est[2,] <- estdlaplace2(x, method="M")
est[3,] <- estdlaplace2(x, method="ML")
est[4,] <- estdlaplace2(x, method="P")
est[5,] <- estdlaplace2(x, method="MM")
dimnames(est)[[1]]<-c("true","M","ML","P","MM")
dimnames(est)[[2]]<-c("p","q")
xlim <- c(min(est[,1])*.98,max(est[,1])*1.02)
ylim <- c(min(est[,2])*.98,max(est[,2])*1.02)
plot(est, pch=19, col=1:5, xlim=xlim, ylim=ylim)
text(est, dimnames(est)[[1]], pos=3, col=1:5, cex= .75)

Inverse of Fisher Information matrix

Description

Inverse of Fisher Information matrix for the DSL.

Usage

iFI(p, q)

Arguments

p

first parameter pp, in (0,1)(0,1), of the DSL

q

second parameter qq, in (0,1)(0,1), of the DSL

Value

The inverse of Fisher Information matrix. Take a look at the references for more details.

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

T. J. Kozubowski, S. Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571

See Also

iFI2

Examples

p <- 0.2
q <- 0.8
iFI(p, q)

Inverse of Fisher Information matrix

Description

Inverse of Fisher Information matrix for the ADSL.

Usage

iFI2(p, q)

Arguments

p

first parameter pp, in (0,1)(0,1), of the ADSL

q

second parameter qq, in (0,1)(0,1), of the ADSL

Value

The inverse of Fisher Information matrix. Take a look at the references for more details.

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67

See Also

ioFI2

Examples

p <- 0.2
q <- 0.8
iFI2(p, q)

Inverse of the observed Fisher Information matrix

Description

Inverse of the observed Fisher Information matrix computed on a random sample of ADSL values.

Usage

ioFI2(x)

Arguments

x

a vector of observations from the ADSL

Value

The inverse of the observed Fisher Information matrix.

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67

See Also

iFI2

Examples

n <- 100
p <- 0.4
q <- 0.7
x <- rdlaplace2(n, p, q)
M <- ioFI2(x)
par <- estdlaplace2(x, "ML")
se <- diag(sqrt(M))
par # MLEs
se # standard errors
M # compare with  the inverse of Fisher Information matrix
iFI2(par[1], par[2])/n # with MLEs plugged in
iFI2(p, q)/n # or the true values

Loss function for the method of moments

Description

A loss function used for the implementation of the method of moments (for the ADSL).

Usage

loss(par, x)

Arguments

par

the vector of parameters, p and q, of the ADSL

x

a vector of sample values from the ADSL

Value

The value L=[E(X)m1(x)]2+[E(X2)m2(x)]2L=[E(X)-m_1(x)]^2+[E(X^2)-m_2(x)]^2, where m1m_1 and m2m_2 are the first- and second-order sample moments.

Author(s)

Alessandro Barbiero, Riccardo Inchingolo

References

A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67

See Also

estdlaplace2, Edlaplace2

Examples

p <- 0.3
q <- 0.7
x <- rdlaplace2(n=100, p, q)
par <- estdlaplace2(x, "M")
loss(par, x) # should be near zero
loss(c(p,q), x) # may be far greater than zero