| nbinom2 | R Documentation |
Probability mass function, distribution function, quantile function, and random generation for the negative binomial distribution reparameterised in terms of mean and size.
dnbinom2(x, mu, size, log = FALSE)
pnbinom2(q, mu, size, lower.tail = TRUE, log.p = FALSE)
qnbinom2(p, mu, size, lower.tail = TRUE, log.p = FALSE)
rnbinom2(n, mu, size)
x, q |
vector of quantiles |
mu |
mean parameter, must be positive. |
size |
size parameter, must be positive. |
log, log.p |
logical; if |
lower.tail |
logical; if |
p |
vector of probabilities |
n |
number of random values to return. |
This implementation allows for automatic differentiation with RTMB.
pnbinom is an AD-compatible implementation of the standard parameterisation of the CDF, missing from RTMB.
Reparameterises the negative binomial by mean \mu via p = r/(r+\mu):
P(X=k;\,\mu,r) = \binom{k+r-1}{k}\left(\frac{r}{r+\mu}\right)^r\left(\frac{\mu}{r+\mu}\right)^k, \quad k = 0,1,2,\ldots
dnbinom2 gives the density, pnbinom2 gives the distribution function, qnbinom2 gives the quantile function, and rnbinom2 generates random deviates.
set.seed(123)
x <- rnbinom2(1, 1, 2)
d <- dnbinom2(x, 1, 2)
p <- pnbinom2(x, 1, 2)
q <- qnbinom2(p, 1, 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.