Parameters are estimated using asbio::ci.p(). If the population size is not Inf a finite population correction will be applied.

col_binomial(
  n = integer(),
  N = integer(),
  ci_error = 0.05,
  population = Inf,
  method = "agresti.coull",
  summarised = FALSE
)

is_col_binomial(x)

Arguments

n

A numeric vector, the number of successes

N

A numeric vector, the number of Bernoulli trials

ci_error

A numeric vector, the error to be used for calculating confidence intervals

population

A numeric vector, the number of individuals in the population to be used for calculating confidence intervals

method

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.

summarised

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

x

An object to test

Value

An S3 vector of class projectable_col_binomial

Examples


# 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