Learn R Programming

⚠️There's a newer version (0.7.4) of this package.Take me there.

jfa: Bayesian and Classical Audit Sampling

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.

Overview

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

  1. Installation
  2. Cheat sheet
  3. Benchmarks
  4. Statistical tables
  5. Intended workflow
  6. References
  7. Package statistics
  8. Contributing

1. Installation

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

install.packages('jfa')

Alternatively, you can download the development version from GitHub using:

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:

methodDescriptionRequired argumentsReference
noneNo prior informationDerks et al. (2021)
armTranslates risk assessments (ARM)ir and crDerks et al. (2021)
bramBayesian risk assessment model (BRAM)ubTouw and Hoogduin (2011)
medianEqual prior probabilities for (in)tolerable misstatementDerks et al. (2021)
hypothesesCustom prior probabilities for (in)tolerable misstatementpHmin or pHplusDerks et al. (2021)
sampleEarlier samplesampleN and sampleKDerks et al. (2021)
factorWeighted earlier samplesampleN, sampleK, and factorDerks et al. (2021)

Supported options for the likelihood argument:

likelihoodDescriptionReference
binomialBeta prior distribution (+ binomial likelihood)Steele (1992)
poissonGamma prior distribution (+ Poisson likelihood)Stewart (2013)
hypergeometricBeta-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:

likelihoodDescriptionReference
binomialBinomial likelihoodStewart (2012)
poissonPoisson likelihoodStewart (2012)
hypergeometricHypergeometric likelihoodStewart (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:

unitsDescriptionRequired argumentsReference
recordsSampling units are itemsLeslie, Teitlebaum, and Anderson (1979)
musSampling units are monetary unitsbookValuesLeslie, Teitlebaum, and Anderson (1979)

Supported options for the algorithm argument:

algorithmDescriptionRequired arguments
randomSelect random units without the use of an interval
cellSelect a random unit from every interval
intervalSelect a fixed unit from every intervalintervalStartingPoint

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:

methodDescriptionRequired argumentsReference
binomialBinomial likelihoodStewart (2012)
poissonPoisson likelihoodStewart (2012)
hypergeometricHypergeometric likelihoodStewart (2012)
stringerClassical Stringer boundBickel (1992)
stringer-meikleStringer bound with Meikle's correctionMeikle (1972)
stringer-ltaStringer bound with LTA correctionLeslie, Teitlebaum, & Anderson (1979)
stringer-pvzModified Stringer boundPap and van Zuijlen (1996)
rohrbachRohrbach's augmented variance estimatorrohrbachDeltaRohrbach (1993)
momentModified moment boundmomentPoptypeDworin and Grimlund (1984)
coxsnellCox and Snell boundcsA, csB, and csMuCox and Snell (1979)
directDirect estimatorpopulationBookValueTouw and Hoogduin (2011)
differenceDifference estimatorpopulationBookValueTouw and Hoogduin (2011)
quotientQuotient estimatorpopulationBookValueTouw and Hoogduin (2011)
regressionRegression estimatorpopulationBookValueTouw 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.5. - 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.

7. Package statistics

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.

Copy Link

Version

Install

install.packages('jfa')

Monthly Downloads

230

Version

0.5.5

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Koen Derks

Last Published

July 1st, 2021

Functions in jfa (0.5.5)

BuildIt

BuildIt Construction financial statements
jfa-methods

Methods for jfa objects
auditPrior

Create a prior distribution for audit sampling
report

Create a statistical audit sampling report
planning

Plan a statistical audit sample
jfa-package

jfa --- Bayesian and Classical Audit Sampling
auditBF

Function to compute Bayes factors for audit sampling
selection

Select a statistical audit sample
evaluation

Evaluate a statistical audit sample