Learn R Programming

jfa (version 0.4.0)

sampling: Sampling from Audit Populations

Description

WARNING: This function will be deprecated from 0.5.0 onwards. Use selection(). This function takes a data frame and performs sampling according to one of three popular algorithms: random sampling, cell sampling, or fixed interval sampling. Sampling is done in combination with one of two sampling units: records or monetary units The returned object is of class jfaSelection and can be used with associated print() and plot() methods.

Usage

sampling(population, sampleSize, units = "records", algorithm = "random",
         bookValues = NULL, intervalStartingPoint = 1, ordered = TRUE, 
         ascending = TRUE, withReplacement = FALSE, seed = 1)

Arguments

population

a data frame containing the population the auditor wishes to sample from.

sampleSize

the number of observations that need to be selected from the population. Can also be an object of class jfaPlanning.

units

can be either records (default) for record sampling, or mus for monetary unit sampling.

algorithm

can be either one of random (default) for random sampling, cell for cell sampling, or interval for fixed interval sampling.

bookValues

a character specifying the name of the column containing the book values (as in the population data).

intervalStartingPoint

the starting point in the interval (used only in fixed interval sampling)

ordered

if TRUE (default), the population is first ordered according to the value of their book values.

ascending

if TRUE (default), order the population in ascending order.

withReplacement

whether sampling should be performed with replacement. Defaults to FALSE.

seed

seed to reproduce results. Default is 1.

Value

An object of class jfaSelection containing:

population

a data frame containing the input population.

sample

a data frame containing the selected observations.

units

the sampling units that were used for sampling.

algorithm

the algorithm that was used for sampling.

bookValues

if specified, the name of the specified book value column.

Details

This first part of this section elaborates on the possible options for the units argument:

  • records: In record sampling, each observation in the population is seen as a sampling unit. An observation of $5000 is therefore equally likely to be selected as an observation of $500.

  • mus: In monetary unit sampling, each monetary unit in the population is seen as a sampling unit. An observation of $5000 is therefore ten times more likely to be selected as an observation of $500.

This second part of this section elaborates on the possible options for the algorithm argument:

  • random: In random sampling each sampling unit in the population is drawn with equal probability.

  • cell: In cell sampling the sampling units in the population are divided into a number (equal to the sample size) of intervals. From each interval one sampling unit is selected with equal probability.

  • interval: In fixed interval sampling the sampling units in the population are divided into a number (equal to the sample size) of intervals. From each interval one sampling unit is selected according to a fixed starting point (intervalStartingPoint).

References

Wampler, B., & McEacharn, M. (2005). Monetary-unit sampling using Microsoft Excel. The CPA journal, 75(5), 36.

See Also

auditPrior planning evaluation

Examples

Run this code
# NOT RUN {
library(jfa)
set.seed(1)

# Generate some audit data (N = 1000).
population <- data.frame(ID = sample(1000:100000, size = 1000, replace = FALSE), 
                         bookValue = runif(n = 1000, min = 700, max = 1000))

# Draw a custom sample of 100 from the population (via random record sampling):

s1 <- sampling(population = population, sampleSize = 100, algorithm = "random", 
               units = "records", seed = 1)
print(s1)

# ------------------------------------------------------------
#                  jfa Selection Summary
# ------------------------------------------------------------
# Input:
#       
# Population size:         1000 
# Requested sample size:   100 
# Sampling units:          Records 
# Algorithm:               Random sampling   
# ------------------------------------------------------------ 
# Output:
# 
# Obtained sample size:    100 
# ------------------------------------------------------------
# Statistics:
#
# Proportion n/N:          0.1 
# ------------------------------------------------------------  

# Use the result from the planning stage in the sampling stage:

p1 <- planning(materiality = 0.05, confidence = 0.95, expectedError = 0.025, 
               likelihood = "binomial")

# Draw a sample via random monetary unit sampling:
s2 <- sampling(population = population, sampleSize = p1, algorithm = "random", 
               units = "mus", seed = 1, bookValues = "bookValue")
print(s2)

# ------------------------------------------------------------
#                  jfa Selection Summary
# ------------------------------------------------------------
# Input:
#      
# Population size:         1000 
# Requested sample size:   234 
# Sampling units:          Monetary units 
# Algorithm:               Random sampling   
# ------------------------------------------------------------ 
# Output:
#
# Obtained sample size:    234 
# ------------------------------------------------------------
# Statistics:
#
# Proportion n/N:          0.23 
# Percentage of value:     23.06% 
# ------------------------------------------------------------ 

# }

Run the code above in your browser using DataLab