Title: | Sum of Independent Non-Identical Binomial Random Variables |
---|---|
Description: | Density function, distribution function, quantile function and random number generation for the sum of independent non-identical binomial distribution with parameters size and prob. For more see: Boxiang Liu and Thomas Quertermous (2018) The R Journal <https://journal.r-project.org/archive/2018/RJ-2018-011/index.html>. |
Authors: | Boxiang Liu |
Maintainer: | Boxiang Liu <[email protected]> |
License: | GPL-3 |
Version: | 1.0.1 |
Built: | 2024-10-27 05:50:16 UTC |
Source: | https://github.com/boxiangliu/sinib |
Density function, distribution function, quantile function and random number generation for the sum of independent non-identical binomial distribution with parameters size and prob. For more see: Boxiang Liu and Thomas Quertermous (2018) The R Journal <https://journal.r-project.org/archive/2018/RJ-2018-011/index.html>.
Boxiang Liu
Maintainer: Boxiang Liu <[email protected]>
Density function, distribution function, quantile function, and random number generation for the sum of independent non-identical binomial random variables
psinib(q, size, prob, lower.tail = TRUE, log.p = FALSE) dsinib(x, size, prob, log = FALSE) rsinib(n, size, prob) qsinib(p, size, prob)
psinib(q, size, prob, lower.tail = TRUE, log.p = FALSE) dsinib(x, size, prob, log = FALSE) rsinib(n, size, prob) qsinib(p, size, prob)
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. |
Suppose S is a random variable formed by summing R independent non-identical random variables ,
.
size
and prob
should both be vectors of length R. The first elements of size
and prob
specifies , the second elements specifies
, so on and so forth. The probability
is calculated using Daniels' second-order continuity-corrected saddlepoint approximation. The density
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
# Calculating the density and probability: size <- 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 <- 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)
# Calculating the density and probability: size <- 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 <- 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)