The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Type: Package
Title: Sum of Independent Non-Identical Binomial Random Variables
Version: 1.0.0
Date: 2017-05-06
Author: Boxiang Liu
Maintainer: Boxiang Liu <jollier.liu@gmail.com>
Description: Density, distribution function, quantile function and random generation for the sum of independent non-identical binomial distribution with parameters \code{size} and \code{prob}.
License: GPL-3
RoxygenNote: 6.0.1
NeedsCompilation: no
Packaged: 2017-05-11 19:30:42 UTC; boshliu
Repository: CRAN
Date/Publication: 2017-05-12 06:11:13 UTC

Sum of Independent Non-Identical Binomial Random Variables

Description

Density, distribution function, quantile function and random generation for the sum of independent non-identical binomial distribution with parameters size and prob.

Author(s)

Boxiang Liu

Maintainer: Boxiang Liu <jollier.liu@gmail.com>


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 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.

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)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.