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 opensource statistical software program.
For complete documentation of jfa
, visit the package website or download the package manual.
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:
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.
To validate the statistical results, jfa
’s automated unit tests regularly verify the main output from the package against the following benchmarks:
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
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.
auditPrior()
functionThe 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 
Betabinomial 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
planning()
functionThe 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:
selection()
functionThe 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:
evaluation()
functionThe 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)  
stringermeikle 
Stringer bound with Meikle’s correction  Meikle (1972)  
stringerlta 
Stringer bound with LTA correction  Leslie, Teitlebaum, & Anderson (1979)  
stringerpvz 
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
report()
functionThe 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.
jfa
is an opensource 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.