Triangular {logcondiscr} | R Documentation |
Functions to compute a and simulate from a triangular probability mass function
Description
In Balabdaoui et al (2012) the triangular density, defined as
p_x^{a, b, c, d, e} = c(x - a) / (b - a)
for x \in \{a, \ldots, c\}
and
p_x^{a, b, c, d, e} = (e - c)(x - b) / (d - b) + c
for x \in \{c, \ldots, d\}
, was used to illustrate the limit process of the log-concave MLE. In order to provide the code to generate the limit process figure in Balabdaoui et al (2012, see the example in logConDiscrMLE
for the code to generate that figure) the functions dTriangular
and rTriangular
are included in this package. Note that rTriangular
uses the rejection sampling algorithm in Devroye (1987) which was specifically developed to generate random numbers from a log-concave PMF.
Usage
dTriangular(a, b, c, d, e)
rTriangular(n, a, b, c, d, e)
Arguments
a |
Left endpoint of triangular pmf. |
b |
Mode of triangular pmf. |
c |
Height at mode. |
d |
Left endpoint. |
e |
Height at left endpoint. |
n |
Number of random numbers to generate. |
Value
dTriangular
returns a vector containing the value of the PMF at all values in x \in \{a, \ldots, d\}
.
rTriangular
returns a list containing the elements:
rand |
Vector with generated random numbers of length |
x |
Vector |
dens |
Value of the pmf at |
Note
This function is used to generate the plot of the limit process in the help file for the function logConDiscrMLE
.
Author(s)
Kaspar Rufibach (maintainer) kaspar.rufibach@gmail.com
http://www.kasparrufibach.ch
Fadoua Balabdaoui fadoua@ceremade.dauphine.fr
http://www.ceremade.dauphine.fr/~fadoua
Hanna Jankowski hkj@mathstat.yorku.ca
http://www.math.yorku.ca/~hkj
Kathrin Weyermann
References
Balabdaoui, F., Jankowski, H., Rufibach, K., and Pavlides, M. (2013). Maximum likelihood estimation and confidence bands for a discrete log-concave distribution. J. R. Stat. Soc. Ser. B Stat. Methodol., 75(4), 769–790.
Devroye, L. (1987). A simple generator for discrete log-concave distributions. Computing, 39, 87-91.
Examples
## -------------------------------------------------------------
## compute values of triangular density and simulate from it
## -------------------------------------------------------------
a <- 1
b <- 7
c <- 8
d <- 11
e <- 2
n <- 10 ^ 2
## support
x <- seq(a, d, by = 1)
## true density
dens <- dTriangular(a, b, c, d, e)
logdens <- log(dens)
rand <- rTriangular(n, a, b, c, d, e)$rand
## does the same as rTriangular()
rand2 <- sample(x = a:d, size = n, prob = dens, replace = TRUE)