This function calculates the required sample size for an audit, based on the Poisson, binomial, or hypergeometric likelihood. A prior can be specified to perform Bayesian planning. The returned object is of class `jfaPlanning`

and can be used with associated `print()`

and `plot()`

methods.

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

planning(confidence = 0.95, expectedError = 0, likelihood = "poisson", N = NULL, materiality = NULL, minPrecision = NULL, prior = FALSE, kPrior = 0, nPrior = 0, increase = 1, maxSize = 5000)

confidence | the confidence level desired from the confidence bound (on a scale from 0 to 1). Defaults to 0.95, or 95% confidence. |
---|---|

expectedError | a fraction representing the percentage of expected mistakes in the sample relative to the total size, or a number (>= 1) that represents the number of expected mistakes. |

likelihood | can be one of |

N | the population size (required for hypergeometric calculations). |

materiality | a value between 0 and 1 representing the materiality of the audit as a fraction of the total size or value. Can be |

minPrecision | The minimum precision to be obtained. Can be |

prior | whether to use a prior distribution when planning. Defaults to |

kPrior | the prior parameter \(\alpha\) (number of errors in the assumed prior sample). |

nPrior | the prior parameter \(\beta\) (total number of observations in the assumed prior sample). |

increase | the desired increase step for the sample size calculation. |

maxSize | the maximum sample size that is considered for calculations. 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:

the confidence level for the desired population statement.

the specified number of errors as a fraction or as a number.

the specified likelihood.

the population size (only returned in case of a hypergeometric likelihood).

the value of the specified materiality. Can be `NULL`

.

The minimum precision to be obtained. Can be `NULL`

.

the resulting sample size.

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

the number of full errors that are allowed to occur in the sample.

a value specifying the expected upper bound if the sample goes according to plan.

a value specifying the expected precision if the sample goes according to plan.

the assumed population errors (only returned in case of a hypergeometric likelihood).

an object of class `jfaPrior`

that represents the prior distribution.

an object of class `jfaPosterior`

that represents the expected posterior distribution.

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

argument.

`poisson`

: The Poisson likelihood is used as a likelihood for monetary unit sampling (MUS). Its 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 used as a likelihood for record sampling*with*replacement. Its 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 record sampling*without*replacement. Its 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)}$$

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.

Koen Derks, k.derks@nyenrode.nl

library(jfa) # Using the binomial distribution, calculates the required sample size for a # materiality of 5% when 2.5% mistakes are expected to be found in the sample. # Frequentist planning with binomial likelihood: p1 <- planning(confidence = 0.95, expectedError = 0.025, likelihood = "binomial", materiality = 0.05) print(p1)#> # ------------------------------------------------------------ #> # jfa Planning Summary (Frequentist) #> # ------------------------------------------------------------ #> # Input: #> # #> # Confidence: 95% #> # Materiality: 5% #> # Minimum precision: Not specified #> # Likelihood: binomial #> # Expected sample errors: 6 #> # ------------------------------------------------------------ #> # Output: #> # #> # Sample size: 234 #> # ------------------------------------------------------------ #> # Statistics: #> # #> # Expected upper bound: 5% #> # Expected precision: 2.43% #> # ------------------------------------------------------------# ------------------------------------------------------------ # jfa Planning Summary (Frequentist) # ------------------------------------------------------------ # Input: # # Confidence: 95% # Materiality: 5% # Minimum precision: Not specified # Likelihood: binomial # Expected sample errors: 6 # ------------------------------------------------------------ # Output: # # Sample size: 234 # ------------------------------------------------------------ # Statistics: # # Expected upper bound: 5% # Expected precision: 2.43% # ------------------------------------------------------------ # Bayesian planning with prior: prior <- auditPrior(confidence = 0.95, likelihood = "binomial", method = "arm", expectedError = 0.025, materiality = 0.05, cr = 0.6) p3 <- planning(confidence = 0.95, expectedError = 0.025, materiality = 0.05, prior = prior) print(p3)#> # ------------------------------------------------------------ #> # jfa Planning Summary (Bayesian) #> # ------------------------------------------------------------ #> # Input: #> # #> # Confidence: 95% #> # Materiality: 5% #> # Minimum precision: Not specified #> # Likelihood: binomial #> # Prior distribution: beta(α = 2.275, β = 50.725) #> # Expected sample errors: 4.23 #> # ------------------------------------------------------------ #> # Output: #> # #> # Sample size: 169 #> # Posterior distribution: beta(α = 6.5, β = 215.5) #> # ------------------------------------------------------------ #> # Statistics: #> # #> # Expected upper bound: 4.99% #> # Expected precision: 2.49% #> # Expected Bayes factor-+: 9.32 #> # ------------------------------------------------------------# ------------------------------------------------------------ # jfa Planning Summary (Bayesian) # ------------------------------------------------------------ # Input: # # Confidence: 95% # Materiality: 5% # Minimum precision: Not specified # Likelihood: binomial # Prior distribution: beta(2.275, 50.725) # Expected sample errors: 4.23 # ------------------------------------------------------------ # Output: # # Sample size: 169 # Posterior distribution: beta(6.5, 215.5) # ------------------------------------------------------------ # Statistics: # # Expected upper bound: 4.99% # Expected precision: 2.49% # Expected Bayes factor-+: 9.32 # ------------------------------------------------------------