Type: | Package |
Title: | Discrete Laplace Distributions |
Version: | 1.1.1 |
Date: | 2016-04-29 |
Author: | Alessandro Barbiero <alessandro.barbiero@unimi.it>, Riccardo Inchingolo <dott.inchingolo_r@libero.it> |
Maintainer: | Alessandro Barbiero <alessandro.barbiero@unimi.it> |
Description: | Probability mass function, distribution function, quantile function, random generation and estimation for the skew discrete Laplace distributions. |
License: | GPL-2 | GPL-3 [expanded from: GPL] |
LazyLoad: | yes |
Packaged: | 2016-04-30 07:57:45 UTC; Barbiero |
Repository: | CRAN |
Date/Publication: | 2016-05-01 00:46:21 |
NeedsCompilation: | no |
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 <alessandro.barbiero@unimi.it>
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
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 |
q |
the second parameter, in |
Details
E(X;p,q)=\frac{1}{1-p}-\frac{1}{1-q}=\frac{p}{1-p}-\frac{q}{1-q}
,
E(|X|;p,q)=\frac{q(1-p)^2+p(1-q)^2}{(1-qp)(1-q)(1-p)}
,
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
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 |
q |
the first parameter |
Details
For the ADSL distribution,
E(X;p,q)=\frac{\log q}{\log(pq)}\frac{p}{1-p}-\frac{\log p}{\log(pq)}\frac{1}{1-q}
and
E(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)
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 |
q |
the second parameter |
prob |
vector of probabilities |
n |
number of observations |
Details
The pmf of the SDL is given by
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)=\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(X\leq x)=\frac{(1-p)q^{-\lfloor x\rfloor}}{1-pq},x<0
F(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
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 |
q |
the second parameter |
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)=\frac{\log p}{\log (pq)}q^{-(x+1)}(1-q)
for x=\dots, -2, -1
and
P(X=x;p,q)=\frac{\log q}{\log (pq)}p^{x}(1-p)
for x=0, 1, 2, \dots
Its cumulative distribution function is:
F(x;p,q)=\frac{\log p}{\log (pq)}q^{-(\lfloor x \rfloor+1)}
for x<0
and
F(x;p,q)=1-\frac{\log q}{\log (pq)}p^{(\lfloor x \rfloor+1)}
for x\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
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 |
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
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)
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 p
and q
coincide with the maximum likelihood estimates.
Usage
estdlaplace(x)
Arguments
x |
a vector of observations from the DSL |
Details
See the reference.
If
\bar{x}^{+}=\frac{1}{n}\sum_{i=1}^n x_i^{+}
, \bar{x}^{-}=\frac{1}{n}\sum_{i=1}^n x_i^{-}
where x^{+}
and x^{-}
are the positive and the negative parts of x
, respectively: x^{+}=x
if x\geq 0
and zero otherwise, x^{-}=(-x)^{+}
, then
\hat{q}=\frac{2\bar{x}^{-}(1+\bar{x})}{1+2\bar{x}^{-}\bar{x}+\sqrt{1+4\bar{x}^{-}\bar{x}^{+}}}
,
\hat{p}=\frac{\hat{q}+\bar{x}(1-\hat{q})}{1+\bar{x}(1-\hat{q})}
when \bar{x}\geq 0
and
\hat{p}=\frac{2\bar{x}^{+}(1-\bar{x})}{1-2\bar{x}^{+}\bar{x}+\sqrt{1+4\bar{x}^{-}\bar{x}^{+}}}
,
\hat{q}=\frac{\hat{p}-\bar{x}(1-\hat{p})}{1-\bar{x}(1-\hat{p})}
when \bar{x}\leq 0
.
Value
A list comprising
hatp |
estimate of |
hatq |
estimate of |
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
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 |
|
err |
a positive tolerance value, as small as possible, used in the definition of lower and upper bounds of the parameters |
parml |
starting values for |
Value
a vector with the parameter estimates of p
and q
.
Author(s)
Alessandro Barbiero, Riccardo Inchingolo
References
A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67
See Also
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 |
q |
second parameter |
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
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 |
q |
second parameter |
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
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
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, |
x |
a vector of sample values from the ADSL |
Value
The value L=[E(X)-m_1(x)]^2+[E(X^2)-m_2(x)]^2
, where m_1
and m_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
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