jfa is an R package for statistical audit sampling. The package provides functions for planning, performing, evaluating, and reporting an audit sample. Specifically, these functions implement standard audit sampling techniques for calculating sample sizes, selecting items from a population, and evaluating the misstatement from a data sample or from summary statistics. Additionally, the jfa package allows the user to create a prior probability distribution to perform Bayesian audit sampling using these functions.

The package and its intended workflow are also implemented with a graphical user interface in the Audit module of JASP, a free and open-source statistical software program.

## Overview

For complete documentation of jfa, visit the package website or download the package manual.

## 1. Installation

The most recently released version of jfa can be downloaded from CRAN by running the following command in R:

install.packages('jfa')

devtools::install_github('koenderks/jfa')

After installation, the jfa package can be loaded with:

library(jfa)

## 2. Cheat sheet

The cheat sheet below can help you get started with the jfa package and its intended workflow. You can download a pdf version of the cheat sheet here.

## 3. Benchmarks

To validate the statistical results, jfa’s automated unit tests regularly verify the main output from the package against the following benchmarks:

## 4. Statistical tables

Below you can find several informative tables that contain statistical sample sizes, upper limits, and Bayes factors. These tables are created using the planning() and evaluation() functions provided in the package.

Sample sizes

Upper limits

Bayes factors

## 5. Intended workflow

Below you can find an explanation of the available functions in jfa, sorted by their occurrence in the standard audit sampling workflow. For detailed examples of how to use these functions, visit the Get started section on the package website.

### Create a prior distribution with the auditPrior() function

The auditPrior() function creates a prior distribution according to one of several methods, including a translation of the assessments of the inherent risk and control risk from the audit risk model. The function returns an object of class jfaPrior which can be used with associated summary() and plot() methods. Objects with class jfaPrior can also be used as input for the prior argument in other functions.

Full function with default arguments:

auditPrior(method = 'none', likelihood = 'binomial', expectedError = 0,
confidence = 0.95, materiality = NULL, N = NULL,
ir = 1, cr = 1, ub = NULL, pHmin = NULL, pHplus = NULL,
sampleN = 0, sampleK = 0, factor = 1)

Supported options for the method argument:

method Description Required arguments Reference
none No prior information Derks et al. (2021)
arm Translates risk assessments (ARM) ir and cr Derks et al. (2021)
bram Bayesian risk assessment model (BRAM) ub Touw and Hoogduin (2011)
median Equal prior probabilities for (in)tolerable misstatement Derks et al. (2021)
hypotheses Custom prior probabilities for (in)tolerable misstatement pHmin or pHplus Derks et al. (2021)
sample Earlier sample sampleN and sampleK Derks et al. (2021)
factor Weighted earlier sample sampleN, sampleK, and factor Derks et al. (2021)

Supported options for the likelihood argument:

likelihood Description Reference
binomial Beta prior distribution (+ binomial likelihood) Steele (1992)
poisson Gamma prior distribution (+ Poisson likelihood) Stewart (2013)
hypergeometric Beta-binomial prior distribution (+ hypergeometric likelihood) Dyer and Pierce (1991)

Example usage:

# A uniform beta prior distribution
x <- auditPrior(method = 'none', likelihood = 'binomial')

summary(x) # Prints information about the prior distribution

### Plan a sample with the planning() function

The planning() 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. To perform Bayesian planning, the input for the prior argument can be an object of class jfaPrior as returned by the auditPrior() function, or an object of class jfaPosterior as returned by the evaluation() function.

Full function with default arguments:

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

Supported options for the likelihood argument:

likelihood Description Reference
binomial Binomial likelihood Stewart (2012)
poisson Poisson likelihood Stewart (2012)
hypergeometric Hypergeometric likelihood Stewart (2012)

Example usage:

# Planning using binomial likelihood
x <- planning(materiality = 0.03, likelihood = 'binomial', confidence = 0.95)

summary(x) # Prints information about the planning

### Select items with the selection() function

The selection() function takes a data frame and performs statistical sampling according to one of three algorithms: random sampling, cell sampling, or fixed interval sampling in combination with either record sampling or monetary unit sampling. The function returns an object of class jfaSelection which can be used with associated summary() and plot() methods. The input for the sampleSize argument can be an object of class jfaPlanning as returned by the planning() function.

Full function with default arguments:

selection(population, sampleSize, units = 'records', algorithm = 'random',
bookValues = NULL, intervalStartingPoint = 1, ordered = TRUE,
ascending = TRUE, withReplacement = FALSE, seed = 1)

Supported options for the units argument:

units Description Required arguments Reference
records Sampling units are items Leslie, Teitlebaum, and Anderson (1979)
mus Sampling units are monetary units bookValues Leslie, Teitlebaum, and Anderson (1979)

Supported options for the algorithm argument:

algorithm Description Required arguments
random Select random units without the use of an interval
cell Select a random unit from every interval
interval Select a fixed unit from every interval intervalStartingPoint

Example usage:

# Selection using fixed interval record sampling
x <- selection(population = BuildIt, sampleSize = 100, units = 'records', algorithm = 'interval')

summary(x) # Prints information about the selection

### Evaluate a sample with the evaluation() function

The evaluation() function takes a sample or summary statistics of the sample and performs evaluation according to the specified method and sampling objectives. The function returns an object of class jfaEvalution which can be used with associated summary() and plot() methods. To perform Bayesian evaluation, the input for the prior argument can be an object of class jfaPrior as returned by the auditPrior() function, or an object of class jfaPosterior as returned by the evaluation() function.

Full function with default arguments:

evaluation(materiality = NULL, minPrecision = NULL, method = 'binomial',
confidence = 0.95, sample = NULL, bookValues = NULL, auditValues = NULL,
counts = NULL, nSumstats = NULL, kSumstats = NULL,
N = NULL, populationBookValue = NULL,
prior = FALSE, nPrior = 0, kPrior = 0,
rohrbachDelta = 2.7, momentPoptype = 'accounts',
csA = 1, csB = 3, csMu = 0.5)

Supported options for the method argument:

method Description Required arguments Reference
binomial Binomial likelihood Stewart (2012)
poisson Poisson likelihood Stewart (2012)
hypergeometric Hypergeometric likelihood Stewart (2012)
stringer Classical Stringer bound Bickel (1992)
stringer-meikle Stringer bound with Meikle’s correction Meikle (1972)
stringer-lta Stringer bound with LTA correction Leslie, Teitlebaum, & Anderson (1979)
stringer-pvz Modified Stringer bound Pap and van Zuijlen (1996)
rohrbach Rohrbach’s augmented variance estimator rohrbachDelta Rohrbach (1993)
moment Modified moment bound momentPoptype Dworin and Grimlund (1984)
coxsnell Cox and Snell bound csA, csB, and csMu Cox and Snell (1979)
direct Direct estimator populationBookValue Touw and Hoogduin (2011)
difference Difference estimator populationBookValue Touw and Hoogduin (2011)
quotient Quotient estimator populationBookValue Touw and Hoogduin (2011)
regression Regression estimator populationBookValue Touw and Hoogduin (2011)

Example usage:

# Binomial evaluation using summary statistics from a sample
x <- evaluation(materiality = 0.03, confidence = 0.95, nSumstats = 100, kSumstats = 1, method = 'binomial')

summary(x) # Prints information about the evaluation

### Create a report with the report() function

The report() function takes an object of class jfaEvaluation as returned by the evaluation() function and automatically creates a html or pdf report containing the analysis results and their interpretation.

Full function with default arguments:

report(object, file = 'report.html', format = 'html_document')

Example usage:

# Generate an automatic report
report(object = x, file = 'myReport.html')

For an example report, see the following link.

## 6. References

• Bickel, P. J. (1992). Inference and auditing: The Stringer bound. International Statistical Review, 60(2), 197–209. - View online
• Cox, D. R., & Snell, E. J. (1979). On sampling and the estimation of rare errors. Biometrika, 66(1), 125-132. - View online
• Derks, K. (2021). jfa: Bayesian and classical audit sampling. R package version 0.5.7. - View online
• 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. - View online
• Dworin, L. D. and Grimlund, R. A. (1984). Dollar-unit sampling for accounts receivable and inventory. The Accounting Review, 59(2), 218–241. - View online
• Dyer, D., & Pierce, R. L. (1993). On the choice of the prior distribution in hypergeometric sampling. Communications in Statistics - Theory and Methods, 22(8), 2125-2146. - View online
• Meikle, G. R. (1972). Statistical Sampling in an Audit Context. Canadian Institute of Chartered Accountants.
• Leslie, D. A., Teitlebaum, A. D., & Anderson, R. J. (1979). Dollar-unit Sampling: A Practical Guide for Auditors. London: Pitman.
• Pap, G., & van Zuijlen, M. C. (1996). On the asymptotic behaviour of the Stringer bound. Statistica Neerlandica, 50(3), 367-389. - View online
• Rohrbach, K. J. (1993). Variance augmentation to achieve nominal coverage probability in sampling from audit populations. Auditing: A Journal of Practice & Theory, 12(2), 79-97.
• Steele, A. (1992). Audit Risk and Audit Evidence: The Bayesian Approach to Statistical Auditing. San Diego: Academic Press.
• Stewart, T. R. (2012). Technical Notes on the AICPA Audit Guide Audit Sampling. American Institute of Certified Public Accountants, New York. - View online
• Stewart, T. R. (2013). A Bayesian Audit Assurance Model with Application to the Component Materiality problem in Group Audits. VU University, Amsterdam. - View online
• Talens, E. (2005). Statistical Auditing and the AOQL-method. University of Groningen, Groningen. - View online
• Touw, P., and Hoogduin, L. (2011). Statistiek voor Audit en Controlling. Boom uitgevers, Amsterdam.

## 8. Contributing

jfa is an open-source project that aims to be useful for the audit community. Your help in benchmarking and extending jfa is therefore greatly appreciated. Contributing to jfa does not have to take much time or knowledge, and there is extensive information available about it on the Wiki of this repository.

If you are willing to contribute to the improvement of the package by adding a benchmark, please check out the Wiki page on how to contribute a benchmark to jfa. If you are willing to contribute to the improvement of the package by adding a new statistical method, please check the Wiki page on how to contribute a new method to jfa.