Learn R Programming

audit (version 0.1-2)

simulateT: Simulating the Total Number of Accounts in Error

Description

Considered a stratified finite population of accounts where each account is classified as either acceptable or in error. Based on a stratified random sample of accounts an auditor is required to give an upper 95 the population that are in error. Given the sample this uses the posterior distribution from a simple hierarchical Bayes model to simulate possible values for T. The 0.95 quantile for this posterior will be an approximate 95 populations.

Usage

simulateT(smp,n,N,grd,R)

Arguments

smp

numeric vector of the number of accounts in error in each strata in the sample

n

numeric vector of the number of accounts sampled in each strata in the population

N

numeric vector of the total number of accounts in each strata in the population

grd

numeric vector of values usually taken to be seq(0.0001,0.1499,length = 11)

R

an integer which is the number of simulated values of T returned

Value

A vector of length R containing simulated values of T

References

Meeden, G. and Sargent, D. (2007) Some Bayesian methods for two auditing problems. Communications in Statistics --- Theory and Methods, 36, 2727--2740. 10.1080/03610920701386802.

Examples

Run this code
# NOT RUN {
grd <- seq(0.0001,0.15,length = 11)
smp <- c(2,1,0)
n <- c(75,50,25)
N <- c(5000,3000,2000)
as.numeric(quantile(simulateT(smp,n,N,grd,40000),0.95))
# }

Run the code above in your browser using DataLab