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 |
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.
Package: | DiscreteLaplace |
Type: | Package |
Version: | 1.1.1 |
Date: | 2016-04-29 |
License: | GPL |
LazyLoad: | yes |
Alessandro Barbiero, Riccardo Inchingolo
Maintainer: Alessandro Barbiero <[email protected]>
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
The function computes the probability mass function, the cumulative distribution function, the quantile function of the DSL and implements random generation.
ddlaplace(x, p, q) pdlaplace(x, p, q) qdlaplace(prob, p, q) rdlaplace(n, p, q)
ddlaplace(x, p, q) pdlaplace(x, p, q) qdlaplace(prob, p, q) rdlaplace(n, p, q)
x |
vector of quantiles |
p |
the first parameter |
q |
the second parameter |
prob |
vector of probabilities |
n |
number of observations |
The pmf of the SDL is given by
whereas the cumulative distribution function is given by
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.
Alessandro Barbiero, Riccardo Inchingolo
Tomasz J. Kozubowski, Seidu Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571
# 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)
# 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)
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
ddlaplace2(x, p, q) palaplace2(x, p, q) pdlaplace2(x, p, q) qdlaplace2(prob, p, q) rdlaplace2(n, p, q)
ddlaplace2(x, p, q) palaplace2(x, p, q) pdlaplace2(x, p, q) qdlaplace2(prob, p, q) rdlaplace2(n, p, q)
x |
vector of quantiles |
p |
the first parameter |
q |
the second parameter |
prob |
vector of probabilities |
n |
number of observations |
The probability mass funtion of the ADSL distribution is given by:
for
and
for
Its cumulative distribution function is:
for
and
for
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.
Alessandro Barbiero, Riccardo Inchingolo
A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67
# 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))
# 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 (changed in sign) for the ADSL distribution.
dlaplacelike2(par, x)
dlaplacelike2(par, x)
par |
the vector of parameters |
x |
a vector of observations from ADSL |
The log-likelihood function with changed sign.
Alessandro Barbiero, Riccardo Inchingolo
A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67
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)
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)
The function provides the expected value and the variance of the SDL, and the expectation of its absolute value.
Edlaplace(p, q)
Edlaplace(p, q)
p |
the first parameter, in |
q |
the second parameter, in |
,
,
A list of three items:
E1 |
expected value |
E1a |
expectation of the absolute value |
V |
variance |
Alessandro Barbiero, Riccardo Inchingolo
T. J. Kozubowski, S. Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571
# ex.1 p<-0.5 q<-0.4 Edlaplace(p, q) # ex.2 p<-0.1 q<-0.9 Edlaplace(p, q)
# 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 moment of the ADSL distribution.
Edlaplace2(p, q)
Edlaplace2(p, q)
p |
the first parameter |
q |
the first parameter |
For the ADSL distribution,
and
A list containing the first- and the second-order moments of the ADSL distribution, E1
and E2
.
Alessandro Barbiero, Riccardo Inchingolo
A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67
estdlaplace2
, loss
, ddlaplace2
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)
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)
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 and
coincide with the maximum likelihood estimates.
estdlaplace(x)
estdlaplace(x)
x |
a vector of observations from the DSL |
See the reference.
If
,
where
and
are the positive and the negative parts of
, respectively:
if
and zero otherwise,
, then
,
when and
,
when .
A list comprising
hatp |
estimate of |
hatq |
estimate of |
hatSigma |
estimate of the inverse of the Fisher information matrix |
Alessandro Barbiero, Riccardo Inchingolo
T. J. Kozubowski, S. Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571
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]
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]
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.
estdlaplace2(x, method = "M", err = 0.001, parml = c(exp(-1), exp(-1)))
estdlaplace2(x, method = "M", err = 0.001, parml = c(exp(-1), exp(-1)))
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 |
a vector with the parameter estimates of and
.
Alessandro Barbiero, Riccardo Inchingolo
A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67
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)
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 for the DSL.
iFI(p, q)
iFI(p, q)
p |
first parameter |
q |
second parameter |
The inverse of Fisher Information matrix. Take a look at the references for more details.
Alessandro Barbiero, Riccardo Inchingolo
T. J. Kozubowski, S. Inusah (2006) A skew Laplace distribution on integers, Annals of the Institute of Statistical Mathematics, 58: 555-571
p <- 0.2 q <- 0.8 iFI(p, q)
p <- 0.2 q <- 0.8 iFI(p, q)
Inverse of Fisher Information matrix for the ADSL.
iFI2(p, q)
iFI2(p, q)
p |
first parameter |
q |
second parameter |
The inverse of Fisher Information matrix. Take a look at the references for more details.
Alessandro Barbiero, Riccardo Inchingolo
A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67
p <- 0.2 q <- 0.8 iFI2(p, q)
p <- 0.2 q <- 0.8 iFI2(p, q)
Inverse of the observed Fisher Information matrix computed on a random sample of ADSL values.
ioFI2(x)
ioFI2(x)
x |
a vector of observations from the ADSL |
The inverse of the observed Fisher Information matrix.
Alessandro Barbiero, Riccardo Inchingolo
A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67
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
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
A loss function used for the implementation of the method of moments (for the ADSL).
loss(par, x)
loss(par, x)
par |
the vector of parameters, |
x |
a vector of sample values from the ADSL |
The value , where
and
are the first- and second-order sample moments.
Alessandro Barbiero, Riccardo Inchingolo
A. Barbiero, An alternative discrete Laplace distribution, Statistical Methodology, 16: 47-67
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
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