This function calculates the minimum sample size for a statistical audit sample based on the binomial, Poisson, 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, minPrecision = NULL, expectedError = 0,
likelihood = 'binomial', confidence = 0.95, N = NULL,
prior = FALSE, nPrior = 0, kPrior = 0,
increase = 1, maxSize = 5000)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 minPrecision should be specified in that case.
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.
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.
a character specifying the likelihood assumed in the calculation. This can be either binomial for the binomial likelihood, poisson for the Poisson likelihood, or hypergeometric for the hypergeometric likelihood. See the details section for more information about the available likelihoods.
a numeric value between 0 and 1 specifying the confidence level used in the planning. Defaults to 0.95 for 95% confidence.
an integer larger than 0 specifying the total population size. Only required when likelihood = 'hypergeometric'.
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 negligible prior distribution is chosen by default, but can be adjusted using the kPrior and nPrior arguments. 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.
if prior = TRUE, a numeric value larger than, or equal to, 0 specifying the sample size of the sample equivalent to the prior information.
if prior = TRUE, a numeric value larger than, or equal to, 0 specifying the sum of errors in the sample equivalent to the prior information.
an integer larger than 0 specifying the desired increase step for the sample size calculation.
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).
An object of class jfaPlanning containing:
a numeric value between 0 and 1 indicating the confidence level.
a numeric value between 0 and 1 indicating the specified materiality. Can be NULL.
a numeric value between 0 and 1 indicating the minimum precision to be obtained. Can be NULL.
a numeric value larger than, or equal to, 0 indicating the expected errors input.
a character indicating the specified likelihood.
an integer larger than 0 indicating the population size (only returned if N is specified).
an integer larger than 0 indicating the required sample size.
a character indicating whether the expected errors where specified as a percentage or as an integer.
a numeric value larger than, or equal to, 0 indicating the number of errors that are allowed in the sample.
a numeric value between 0 and 1 indicating the expected upper bound if the sample goes according to plan.
a numeric value between 0 and 1 indicating the expected precision if the sample goes according to plan.
if likelihood = 'hypergeometric', an integer larger than 0 indicating the assumed population errors.
if a prior distribution is specified, an object of class jfaPrior that contains information about the prior distribution.
if a prior distribution is specified, an object of class jfaPosterior that contains information about the expected posterior distribution.
This section elaborates on the available likelihoods and corresponding prior distributions for the likelihood argument.
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}$$
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)}$$
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)}$$
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, 1-16.
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.
# NOT RUN {
# Frequentist planning using a binomial likelihood
planning(materiality = 0.05, expectedError = 0.025, likelihood = 'binomial')
# Bayesian planning using a negligible beta prior
planning(materiality = 0.05, expectedError = 0.025, likelihood = 'binomial',
prior = TRUE)
# Bayesian planning using an informed beta prior
planning(materiality = 0.05, expectedError = 0.025, likelihood = 'binomial',
prior = auditPrior(method = 'median', materiality = 0.05))
# }
Run the code above in your browser using DataLab