projectable_col_binomial
.R/col_binomial.R
col_binomial.Rd
Parameters are estimated using asbio::ci.p()
. If the population size is not
Inf
a finite population correction will be applied.
A numeric vector, the number of successes
A numeric vector, the number of Bernoulli trials
A numeric vector, the error to be used for calculating confidence intervals
A numeric vector, the number of individuals in the population to be used for calculating confidence intervals
The name of a method to be passed through to asbio::ci.p()
for
parameter estimation. The default is "agresti.coull", but other options
include "asymptotic", "score", "LR" and "exact". See asbio::ci.p()
for details.
A logical flagging whether or not n
and N
are being
supplied in summarised form or not. If FALSE, n
and N
will be summed
across to calculate the number of successes and trials respectively
An object to test
An S3 vector of class projectable_col_binomial
# Calculate and store summary statistics for a binomial distribution
b_trials <- stats::rbinom(1000, 1, 0.5)
col_binomial(b_trials)
#> <col_binomial[1]>
#> [1] 0.5
# Store pre-calculated summary statistics for a binomial distribution
b_trials <- lapply(1:5, function(x) stats::rbinom(1000, 1, 0.5))
n_successes <- vapply(b_trials, function(x) sum(x), integer(1))
n_sample <- vapply(b_trials, length, integer(1))
col_binomial(n_successes, n_sample, summarised = TRUE)
#> <col_binomial[5]>
#> [1] 0.53 0.50 0.49 0.52 0.49