psinib {sinib} | R Documentation |
Distribution of Sum of Independent Non-Identical Binomial Random Variables
Description
Density, distribution function, quantile function, and random number generation for the sum of independent non-identical binomial random variables
Usage
psinib(q, size, prob, lower.tail = TRUE, log.p = FALSE)
dsinib(x, size, prob, log = FALSE)
rsinib(n, size, prob)
qsinib(p, size, prob)
Arguments
size |
integer vector of number of trials (see detail). |
prob |
numeric vector of success probabilities (see detail). |
lower.tail |
logical; if TRUE, probabilities are |
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. |
Details
Suppose S is a random variable formed by summing R independent non-identical random variables X_r
, r = 1,...,R
.
S = \sum_{r=1}^R X_r
size
and prob
should both be vectors of length R. The first elements of size
and prob
specifies X_1
, the second elements specifies X_2
, 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.
Value
qsinib gives the cumulative distribution of sum of independent non-identical random variables.
Source
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
Examples
# 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)