Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Audit Sampling & Materiality Toolkit (R)

An end-to-end simulation of the three quantitative hearts of a financial statement audit — materiality, sample selection, and misstatement projection — built in R and validated against a population with known, seeded errors.

The headline result: a Monetary Unit Sample of 877 invoices caught only 5 of the 30 errors seeded into a 20,000-invoice ledger, yet projected total misstatement of 371,867 PLN against a true value of 380,000 PLN — 98% accuracy — while a 500-item classical stratified sample caught zero errors and projected zero. The toolkit demonstrates, with numbers rather than opinions, why value-weighted sampling dominates audit practice.

Population

What it does

  1. Synthetic population generator — a right-skewed sales ledger (~20k invoices, log-normal amounts, high-value key items, a consistent receivables register and financial statements), with 30 overstatement errors totalling exactly 380,000 PLN seeded and recorded in an answer key that the "audit" never uses. Fixed seed = every number reproducible.
  2. Materiality calculator (ISA 320 concepts) — overall materiality with benchmark-selection logic (profit / revenue / assets / equity), performance materiality (50–75%), clearly trivial threshold, and an auto-generated planning memo.
  3. Sampling module (ISA 530 concepts) — key-item split at performance materiality, MUS sample sizing (n = BV·RF/(TM − EM·EF)) with step-by-step systematic value-weighted selection, attribute sampling for tests of controls, and a stratification study (Neyman allocation) showing why classical variables sampling needs a near-census on skewed populations.
  4. Evaluation module — Stringer-bound MUS evaluation (most likely error, basic precision, incremental allowance, upper error limit), stratified difference estimation, and an accept / extend / adjust / qualify decision — then an honesty check against the seeded truth.

MUS weighting

The audit logic in five sentences

Materiality is the size of misstatement that would change a user's decisions; the auditor works to a lower performance materiality so that detected plus undetected errors stay below it. Items larger than performance materiality could individually be material, so they are tested 100% and only the remainder is sampled. MUS treats every złoty — not every invoice — as the sampling unit, so large invoices are selected with near-certainty and each error found projects onto the monetary interval it represents. The projection (not the errors found) is compared to tolerable misstatement, and the upper error limit prices in what the sample might have missed. If even the best estimate exceeds tolerable misstatement, the auditor requests adjustment — and failing that, qualifies the opinion.

Results at a glance

Quantity PLN
True seeded misstatement (answer key) 380 000
MUS most likely error (n = 877, 5 errors found) 371 867
MUS upper error limit (Stringer, 5% risk) 964 368
Stratified projection (n = 500, 0 errors found) 0
Performance materiality 390 000
Conclusion grey zone → correct factual errors / extend testing

The engagement deliberately lands in the grey zone (MLE just below tolerable misstatement, upper error limit far above it) — the situation that actually exercises audit judgment, rather than a textbook "accept".

Repository structure

R/
  generate_data.R        # synthetic population + seeded errors
  materiality.R          # ISA 320-style thresholds + planning memo
  sampling.R             # key items, MUS, attribute, stratification
  evaluation.R           # Stringer bound, difference estimation, conclusion
  run_module0_check.R .. run_module3_check.R   # runnable step-by-step demos
notebooks/
  audit_sampling_report.Rmd   # the full pipeline as a narrated report
output/
  audit_sampling_report.html  # rendered report + all figures
data/                    # generated CSVs (reproducible; git-ignored)

Quick start

# requires: dplyr, ggplot2, tidyr, scales, rmarkdown
Rscript R/run_module0_check.R   # generate population
Rscript R/run_module1_check.R   # materiality
Rscript R/run_module2_check.R   # sampling
Rscript R/run_module3_check.R   # evaluation vs seeded truth
Rscript -e 'rmarkdown::render("notebooks/audit_sampling_report.Rmd", output_dir = "output")'

Limitations

Synthetic data is cleaner than any real ledger: no credit notes or negative amounts (which MUS handles badly), no duplicates, no foreign currency, no unreconciled balances — so the hardest practical step, reconciling and cleaning the population before sampling, is out of scope. Threshold percentages (5% of PBT, 75% PM, 5% CT) are common methodology conventions, not rules. A real engagement combines tests of details with controls testing and substantive analytics; this project isolates the sampling leg on purpose. Concepts follow ISA 320 and ISA 530; this is a learning project, not firm methodology.

About

Materiality, audit sampling (MUS) and misstatement projection toolkit in R — validated against a population with seeded errors

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages