Description Usage Arguments Details Value Source Examples
Density, distribution function, quantile function, and random number generation for the sum of independent non-identical binomial random variables
1 2 3 4 5 6 7 |
size |
integer vector of number of trials (see detail). |
prob |
numeric vector of success probabilities (see detail). |
lower.tail |
logical; if TRUE, probabilities are P[S<=s], otherwise, P[S>s]. |
x, q |
integer vector of quantiles. |
log, log.p |
logical; if TRUE, probabilities p are given as log(p). |
n |
numeric scalar to indicate number of observations. |
p |
numeric vector of probabilities. |
Suppose S is a random variable formed by summing R independent non-identical random variables Xr, r = 1,...,R.
S = X1+X2+...XR
size
and prob
should both be vectors of length R. The first elements of size
and prob
specifies X1, the second elements specifies X2, so on and so forth. The probability F(S) is calculated using Daniels' second-order continuity-corrected saddlepoint approximation. The density p(S) is calculated using second-order saddlepoint mass approximation with Butler's normalization.
qsinib gives the cumulative distribution of sum of independent non-identical random variables.
See Eisinga et al (2012) Saddlepoint approximations for the sum of independent non-identically distributed binomial random variables. Available from http://onlinelibrary.wiley.com/doi/10.1111/stan.12002/full
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Calculating the density and probability:
size <- as.integer(c(12, 14, 4, 2, 20, 17, 11, 1, 8, 11))
prob <- c(0.074, 0.039, 0.095, 0.039, 0.053, 0.043, 0.067, 0.018, 0.099, 0.045)
q <- x <- as.integer(seq(1, 19, 2))
dsinib(x, size, prob)
psinib(q, size, prob)
# Generating random samples:
rsinib(100, size, prob)
# Calculating quantiles:
p <- psinib(q, size, prob)
qsinib(p, size, prob)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.