# NOT RUN {
library(jfa)
# Using the binomial distribution, calculates the required sample size for a
# materiality of 5% when 2.5% mistakes are expected to be found in the sample.
# Frequentist planning with binomial likelihood:
p1 <- planning(confidence = 0.95, expectedError = 0.025, likelihood = "binomial",
materiality = 0.05)
print(p1)
# ------------------------------------------------------------
# jfa Planning Summary (Frequentist)
# ------------------------------------------------------------
# Input:
#
# Confidence: 95%
# Materiality: 5%
# Minimum precision: Not specified
# Likelihood: binomial
# Expected sample errors: 6
# ------------------------------------------------------------
# Output:
#
# Sample size: 234
# ------------------------------------------------------------
# Statistics:
#
# Expected upper bound: 5%
# Expected precision: 2.43%
# ------------------------------------------------------------
# Bayesian planning with prior:
prior <- auditPrior(confidence = 0.95, likelihood = "binomial", method = "arm",
expectedError = 0.025, materiality = 0.05, cr = 0.6)
p3 <- planning(confidence = 0.95, expectedError = 0.025, materiality = 0.05,
prior = prior)
print(p3)
# ------------------------------------------------------------
# jfa Planning Summary (Bayesian)
# ------------------------------------------------------------
# Input:
#
# Confidence: 95%
# Materiality: 5%
# Minimum precision: Not specified
# Likelihood: binomial
# Prior distribution: beta(2.275, 50.725)
# Expected sample errors: 4.23
# ------------------------------------------------------------
# Output:
#
# Sample size: 169
# Posterior distribution: beta(6.5, 215.5)
# ------------------------------------------------------------
# Statistics:
#
# Expected upper bound: 4.99%
# Expected precision: 2.49%
# Expected Bayes factor-+: 9.32
# ------------------------------------------------------------
# }
Run the code above in your browser using DataLab