Learn R Programming

extraDistr (version 1.8.1)

PropBeta: Beta distribution of proportions

Description

Probability mass function, distribution function and random generation for the reparametrized beta distribution.

Usage

dprop(x, size, mean, log = FALSE)
pprop(q, size, mean, lower.tail = TRUE, log.p = FALSE)
qprop(p, size, mean, lower.tail = TRUE, log.p = FALSE)
rprop(n, size, mean)

Arguments

x, q
vector of quantiles.
size
precision or number of binomial trials (zero or more).
mean
mean proportion or probability of success on each trial; 0 < mean < 1.
log, log.p
logical; if TRUE, probabilities p are given as log(p).
lower.tail
logical; if TRUE (default), probabilities are $P[X \le x]$ otherwise, $P[X > x]$.
p
vector of probabilities.
n
number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Probability mass function of binomial distribution is

$$ {n \choose k} p^k (1-p) ^{n-k} $$

probability density function of beta distribution is

$$ \frac{1}{\mathrm{B}(\alpha, \beta)} p^{\alpha-1} (1-p)^{\beta-1} $$

we can rewrite

$$ {n \choose k} = \frac{1}{(n+1) \mathrm{B}(k+1, n-k+1)} $$

if we substitute $k+1 = \alpha$ and $n-k+1 = \beta$ then pmf of binomial distribution becomes

$$ \frac{1}{(n+1) \mathrm{B}(\alpha, \beta)} p^{\alpha-1} (1-p)^{\beta-1} $$

so beta can be understood as a distribution of $k/n$ proportions in $n$ trials where the average proportion is denoted as $\mu$

$$ \frac{1}{\mathrm{B}(n\mu, n(1-\mu))} p^{n\mu+1} (1-p)^{n(1-\mu)+1} $$

Alternatively $n$ may be understood as precision parameter.

References

Ferrari, S., & Cribari-Neto, F. (2004). Beta regression for modelling rates and proportions. Journal of Applied Statistics, 31(7), 799-815.

Examples

Run this code

x <- rprop(1e5, 100, 0.33)
xx <- seq(0, 1, by = 0.01)
hist(x, 100, freq = FALSE)
lines(xx, dprop(xx, 100, 0.33), col = "red")
hist(pprop(x, 100, 0.33))
plot(ecdf(x))
lines(xx, pprop(xx, 100, 0.33), col = "red", lwd = 2)
                       

Run the code above in your browser using DataLab