This function calculates the minimum sample size for a statistical audit sample based on the Poisson, binomial, or hypergeometric likelihood. The function returns an object of class jfaPlanning which can be used with associated summary() and plot() methods.

For more details on how to use this function, see the package vignette: vignette('jfa', package = 'jfa')

planning(materiality = NULL, min.precision = NULL, expected = 0,
likelihood = c('poisson', 'binomial', 'hypergeometric'),
conf.level = 0.95, N.units = NULL, by = 1, max = 5000,
prior = FALSE)

## Arguments

materiality

a numeric value between 0 and 1 specifying the performance materiality (i.e., maximum upper limit) as a fraction of the total population size. Can be NULL, but min.precision should be specified in that case.

min.precision

a numeric value between 0 and 1 specifying the minimum precision (i.e., upper bound minus most likely error) as a fraction of the total population size. Can be NULL, but materiality should be specified in that case.

expected

a numeric value between 0 and 1 specifying the expected errors in the sample relative to the total sample size, or a number (>= 1) that represents the number of expected errors in the sample. It is advised to set this value conservatively to minimize the probability of the observed errors exceeding the expected errors, which would imply that insufficient work has been done in the end.

likelihood

a character specifying the likelihood assumed in the calculation. This can be either poisson (default) for the Poisson likelihood, binomial for the binomial likelihood, or hypergeometric for the hypergeometric likelihood. See the details section for more information about the available likelihoods.

conf.level

a numeric value between 0 and 1 specifying the confidence level used in the planning. Defaults to 0.95 for 95% confidence.

N.units

an integer larger than 0 specifying the total number of units or items in the population (i.e., the population size). Only required when likelihood = 'hypergeometric'.

by

an integer larger than 0 specifying the desired increment for the sample size calculation.

max

an integer larger than 0 specifying the maximum sample size that is considered in the calculation. Defaults to 5000 for efficiency. Increase this value if the sample size cannot be found due to it being too large (e.g., for a low materiality).

prior

a logical specifying whether to use a prior distribution when planning, or an object of class jfaPrior or jfaPosterior containing the prior distribution. Defaults to FALSE for frequentist planning. If TRUE, a minimal information prior is chosen by default. Chooses a conjugate gamma distribution for the Poisson likelihood, a conjugate beta distribution for the binomial likelihood, and a conjugate beta-binomial distribution for the hypergeometric likelihood.

## Value

An object of class jfaPlanning containing:

conf.level

a numeric value between 0 and 1 indicating the confidence level used.

x

a numeric value larger than, or equal to, 0 indicating the number of tolerable errors in the sample.

n

an integer larger than 0 indicating the required sample size.

ub

a numeric value between 0 and 1 indicating the expected upper bound if the sample goes according to plan.

precision

a numeric value between 0 and 1 indicating the expected precision if the sample goes according to plan.

p.value

a numeric value indicating the one-sided p-value.

K

if likelihood = 'hypergeometric', an integer larger than 0 indicating the assumed population errors.

N.units

an integer larger than 0 indicating the population size (only returned if N is specified).

materiality

a numeric value between 0 and 1 indicating the specified materiality.

min.precision

a numeric value between 0 and 1 indicating the minimum precision to be obtained.

expected

a numeric value larger than, or equal to, 0 indicating the expected errors input.

likelihood

a character indicating the specified likelihood.

errorType

a character indicating whether the expected errors where specified as a percentage or as an integer.

iterations

a numeric value indicating the number of iterations used.

prior

if a prior distribution is specified, an object of class jfaPrior that contains information about the prior distribution.

posterior

if a prior distribution is specified, an object of class jfaPosterior that contains information about the expected posterior distribution.

## Details

This section elaborates on the available likelihoods and corresponding prior distributions for the likelihood argument.

• poisson: The Poisson likelihood is often used as a likelihood for monetary unit sampling (MUS). The likelihood function is defined as: $$p(x) = \frac{\lambda^x e^{-\lambda}}{x!}$$ The conjugate gamma($$\alpha, \beta$$) prior has probability density function: $$f(x; \alpha, \beta) = \frac{\beta^\alpha x^{\alpha - 1} e^{-\beta x}}{\Gamma(\alpha)}$$

• binomial: The binomial likelihood is often used as a likelihood for attributes sampling with replacement. The likelihood function is defined as: $$p(x) = {n \choose k} p^k (1 - p)^{n - k}$$ The conjugate beta($$\alpha, \beta$$) prior has probability density function: $$f(x; \alpha, \beta) = \frac{1}{B(\alpha, \beta)} x^{\alpha - 1} (1 - x)^{\beta - 1}$$

• hypergeometric: The hypergeometric likelihood is used as a likelihood for sampling without replacement. The likelihood function is defined as: $$p(x = k) = \frac{{K \choose k} {N - K \choose n - k}}{{N \choose n}}$$ The conjugate beta-binomial($$\alpha, \beta$$) prior (Dyer and Pierce, 1993) has probability density function: $$f(k | n, \alpha, \beta) = {n \choose k} \frac{B(k + \alpha, n - k + \beta)}{B(\alpha, \beta)}$$

## References

Derks, K., de Swart, J., van Batenburg, P., Wagenmakers, E.-J., & Wetzels, R. (2021). Priors in a Bayesian audit: How integration of existing information into the prior distribution can improve audit transparency and efficiency. International Journal of Auditing, 25(3), 621-636.

Dyer, D. and Pierce, R.L. (1993). On the choice of the prior distribution in hypergeometric sampling. Communications in Statistics - Theory and Methods, 22(8), 2125 - 2146.

auditPrior selection evaluation report

## Author

Koen Derks, k.derks@nyenrode.nl

## Examples

# Classical planning using a Poisson likelihood
planning(materiality = 0.05, expected = 0.025, likelihood = "poisson")
#>
#> 	Classical Audit Sample Planning
#>
#> minimum sample size = 231
#> sample size obtained in 232 iteration(s) via method 'poisson'

# Bayesian planning using a noninformative gamma prior distribution
planning(
materiality = 0.05, expected = 0.025, likelihood = "poisson",
prior = TRUE
)
#>
#> 	Bayesian Audit Sample Planning
#>
#> minimum sample size = 228
#> sample size obtained in 229 iteration(s) via method 'poisson' + 'prior'

# Bayesian planning using an informed gamma prior distribution
planning(
materiality = 0.05, expected = 0.025, likelihood = "poisson",
prior = auditPrior(method = "impartial", materiality = 0.05)
)
#>
#> 	Bayesian Audit Sample Planning
#>
#> minimum sample size = 189
#> sample size obtained in 190 iteration(s) via method 'poisson' + 'prior'