# 9  R Packages

This chapter discusses other R packages that implement statistical techniques for audit sampling. Such information may be useful for auditors who wish to explore alternative approaches or simply want to confirm the results obtained through the use of the jfa package. By exploring these other packages, auditors can gain a greater understanding of the various options available for audit sample planning, selection and evaluation.

## 9.1 MUS

MUS is an R package providing sampling and evaluation methods to apply Monetary Unit Sampling during an audit of financial statements. The package is available via CRAN and can be downloaded by running the code below. Unlike jfa, the MUS package provides no functionality for Bayesian audit sampling.

install.packages("MUS")

To show the diffences and similarities between the use of the MUS package and the jfa package, consider a scenario in which an auditor wants to plan a monetary unit sample such that the sampling risk can be reduced below five percent. The population in this example consists of $$N$$ = 1000 monetary units and the performance materiality is defined as ten percent (or 100 monetary units). The auditor plans the sample using an expected misstatement rate of one percent (or 10 monetary units).

To compute this sample size, the MUS package provides the MUS.calc.n.conservative() function, which takes the performance materiality in monetary units as the tolerable.error argument, the expected misstatements in monetary units as the expected.error argument, and the total number of unit in the population as the book.value argument. The resulting sample size is 37.

MUS::MUS.calc.n.conservative(tolerable.error = 100, expected.error = 10, book.value = 1000, confidence.level = 0.95)
#> [1] 37

These results can be reproduced in jfa using the following command:

planning(materiality = 0.1, expected = 0.01, likelihood = "poisson")
#>
#>  Classical Audit Sample Planning
#>
#> minimum sample size = 37
#> sample size obtained in 38 iterations via method 'poisson'

## 9.2 samplingbook

samplingbook is an R package based on the book Stichproben: Methoden und praktische Umsetzung mit R that focuses on survey sampling and statistical analysis of these samples. The package is available via CRAN and can be downloaded by running the code below. Unlike jfa, the samplingbook package provides limited functionality for auditing as it mainly focuses on survey sampling.

install.packages("samplingbook")

To show the diffences and similarities between the use of the samplingbook package and the jfa package, consider a scenario in which an auditor wants to evaluate a sample of items and is interested in estimating the 95 percent upper confidence bound. The population in this example consists of $$N$$ = 300 items and the auditor has inspected a sample of $$n$$ = 100 items, of which $$k$$ = 3 contained a misstatement.

To compute the upper bound, the samplingbook package provides the Sprop() function, which takes the number of found misstatements in the sample as the m argument, the sample size as the n argument and the population size as the N argument. Note that because this function solely computes a two-sided interval for the population misstatement, the 95 percent upper bound can be obtained by using an interval of 90 percent with level = 0.9. The resulting upper bound is 0.07.

samplingbook::Sprop(m = 3, n = 100, N = 300, level = 0.90)
#>
#> Sprop object: Sample proportion estimate
#> With finite population correction: N = 300
#>
#> Proportion estimate:  0.03
#> Standard error:  0.014
#>
#> 90% approximate confidence interval:
#>  proportion: [0.007,0.053]
#>  number in population: [3,15]
#> 90% exact hypergeometric confidence interval:
#>  proportion: [0.01,0.07]
#>  number in population: [3,21]

These results can be reproduced in jfa using the following command:

evaluation(x = 3, n = 100, N.units = 300, method = "hypergeometric", alternative = "less", conf.level = 0.95)
#>
#>  Classical Audit Sample Evaluation
#>
#> data:  3 and 100
#> number of errors = 3, number of samples = 100, taint = 3
#> 95 percent confidence interval:
#>  0.00000000 0.06666667
#> most likely estimate:
#>  0.03
#> results obtained via method 'hypergeometric'

## 9.3 audit

audit is an R package based on the paper by Meeden & Sargent (2007) that can be used to find an upper bound for the total amount of overstatement of assets in a set of accounts and estimating the amount of sales tax owed on a collection of transactions. The package is available via CRAN and can be downloaded by running the code below. Unlike jfa, The audit package provides limited functionality for evaluating audit samples and has no functionality for planning and selection.

install.packages("audit")