diff --git a/DESCRIPTION b/DESCRIPTION index f7d5d64..ca0f26f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,14 +3,17 @@ Package: MUS Type: Package Title: Monetary Unit Sampling and Estimation Methods, Widely Used in Auditing -Version: 0.1.4 -Date: 2017-05-29 -Author: Henning Prömpers +Version: 0.1.6 +Date: 2019-09-15 +Author: Henning Prömpers, André Guimarães Maintainer: Henning Prömpers Description: Sampling and evaluation methods to apply Monetary Unit Sampling (or in older literature Dollar Unit Sampling) during an audit of financial statements. -Depends: R (>= 3.3.2), stats +Depends: R (>= 3.4.0), stats +Suggests: DescTools, pander License: GPL (>= 2) NeedsCompilation: no -Packaged: 2017-05-29 11:35:09 UTC; henning +BugReports: https://github.com/alsguimaraes/MUS +Packaged: 2019-09-15 11:06:00 UTC; henning Repository: CRAN -Date/Publication: 2017-05-29 12:59:00 UTC +Date/Publication: 2019-09-15 11:06:00 UTC +RoxygenNote: 6.1.1 diff --git a/MD5 b/MD5 index 014213f..eccf072 100644 --- a/MD5 +++ b/MD5 @@ -1,12 +1,38 @@ -92ef6028f21f3e52cfa959f4b175d688 *DESCRIPTION -ebc82eeabe85c8e859c9188db3f4e2b8 *NAMESPACE -28f87c6f5f4acfa082b367640e383b15 *R/MUS.evaluation.R -131030fc311f00ca7d307d0ab511cf7d *R/MUS.extraction.R -1d9a0a01a4994d8b473b3f76f4bf9bf4 *R/MUS.planning.R -b06b9215961c94e2b5c5d23133f578d1 *R/print.MUS.evaluation.result.R -466cdf8057b5044796def504e2ae97b5 *build/partial.rdb -8d66b1de524e389d4a5c400f05590d6f *man/MUS-package.Rd -80a60a86dd5f76a1d99a4739ccdd3bc7 *man/MUS.evaluation.Rd -8c60a29255dfa4a933cb81811bc64113 *man/MUS.extraction.Rd -88f5baa485a04c1a4cc3006284fb44dc *man/MUS.planning.Rd -e8422b46140bf162d6ca7c2c62b18502 *man/print.MUS.evaluation.result.Rd +a5cc879bbbde2779963efd937f75589b *build/partial.rdb +5f0bc17891b9e08231936ee3590e79ac *DESCRIPTION +5f9db751af196e6747c5fd418b66583b *examples/data.csv +da533b2e22782e7c14d31387afb1bd4d *examples/example.R +bd1409a941923f8e6e9a83db107ea854 *examples/example.Rmd +49c905092eb5ae1fc00206fcdf7ac445 *examples/logo.png +2553531635d707000aa31253b5f274ef *examples/workflow.R +32631548c047c541ee897b741ad2953e *inst/po/en@quot/LC_MESSAGES/R-MUS.mo +31f2543e08e9774dfef16d32bf340954 *inst/po/pt_BR/LC_MESSAGES/R-MUS.mo +b8d9689af48ca28fc3c4c470e293c1c6 *man/MUS-package.Rd +56682d1d63ca32060c7463c69b094219 *man/MUS.binomial.bound.Rd +f01f9da0bce2624bff8da2d4696745d4 *man/MUS.calc.n.conservative.Rd +eeef03ed9e4cb2fbb6cec4bfeea7a3a1 *man/MUS.combine.Rd +f7d247df7d06a60fda55dd180738419e *man/MUS.combined.high.error.rate.Rd +be4052a145e687017fca8029da1c7ab4 *man/MUS.evaluation.Rd +2330e71495709ce7a90a2d5461fb8851 *man/MUS.extend.Rd +7f2320966a4f6827ccaa61dbf8139ed8 *man/MUS.extraction.Rd +292c6ed68ffd431f5c12c62be370ab3b *man/MUS.factor.Rd +3c08c4957450564943a3efc8ff29d955 *man/MUS.moment.bound.Rd +3d79b9c07c9bc7fef7a0a040b0965ad9 *man/MUS.multinomial.bound.Rd +0daddbe026e7bfa835d7fea40ee69343 *man/MUS.planning.Rd +c7e85c735e646069ec888201aaf083b1 *man/print.MUS.evaluation.result.Rd +4e1716e1ea1a4f37d589ec334a6b543b *man/print.MUS.extraction.result.Rd +d0f925ae487b32a55e2487062eef2fb7 *man/print.MUS.planning.result.Rd +1faebf3391ec44409007b4658382bfe9 *NAMESPACE +8e6549ce43e86d56f79f71b83d51f1b8 *po/R-MUS.pot +31f2543e08e9774dfef16d32bf340954 *po/R-pt_BR.mo +a0de8307b4c2e8554329170c9c4c015f *po/R-pt_BR.po +177c1abba09291d8b502a473533589b4 *R/MUS.bounds.R +4108a5e86888565eb8245a56e9cc006d *R/MUS.combine.R +b2a016cc212874e2af2cfce533b8415d *R/MUS.evaluation.R +5b34a0c94786bb478ae075f297ae97f2 *R/MUS.extend.R +6d3e017a312482d5a3ff2b04c5ba756c *R/MUS.extraction.R +4502183f507ae8473a44e9bc5a36cd20 *R/MUS.planning.R +11a67054d6fa4ad2eea4099c74404b71 *R/print.MUS.evaluation.result.R +7758ec42e5ebb60844c92cd8fae4bde5 *R/print.MUS.extraction.result.R +b1214e49ec92ade404dcc845373be121 *R/print.MUS.planning.result.R +42daef4e6a76933a0ac4ebecf31fd3fc *README.md diff --git a/NAMESPACE b/NAMESPACE index 34cce38..22901cf 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,3 +1,5 @@ exportPattern("^[[:alpha:]]+") -importFrom("stats", "phyper", "runif", "uniroot") +importFrom("stats", "phyper", "runif", "uniroot", "aggregate", "qgamma", "qnorm", "qt", "sd") S3method(print, MUS.evaluation.result) +S3method(print, MUS.planning.result) +S3method(print, MUS.extraction.result) diff --git a/R/MUS.bounds.R b/R/MUS.bounds.R new file mode 100644 index 0000000..e489cc8 --- /dev/null +++ b/R/MUS.bounds.R @@ -0,0 +1,128 @@ +MUS.moment.bound <- function(x, confidence.level=0.95, as.pct=FALSE, include.high.values=TRUE) { + # Dworking & Grimlund, 1984 + # data = c(rep(0, 96), -.16, .04, .18, .47) + if (!class(x)=="MUS.evaluation.result" && !is.vector(x)) stop("x has to be a vector or an object of type MUS.evaluation.result. Use function MUS.evaluate to create such an object.") + + if (class(x)=="MUS.evaluation.result") { + data <- c(1 - x$filled.sample[,x$col.name.audit.values] / x$filled.sample[,x$col.name.book.values]) + if (include.high.values && is.data.frame(x$filled.high.values)) { + data <- c(data, (1 - x$filled.high.values[,x$col.name.audit.values] / x$filled.high.values[,x$col.name.book.values])) + } + confidence.level <- x$confidence.level + mult <- ifelse(as.pct, 100, x$Results.Total$Net.most.likely.error[1]) + } else { + data <- x + mult <- 0 + } + + taintings = data[data!=0] + n <- length(taintings) + N <- length(data) + + hypothetical.tainting = 0.81*(1-0.667*tanh(10*mean(taintings)))*(1+0.667*tanh(n/10)) + TN <- sapply(1:3, function(j) (hypothetical.tainting^j+sum(taintings^j))/(n+1)) + RN <- c( ((1+n)/(2+N)), ((1+n)/(2+N)) * ((2+n)/(3+N)), ((1+n)/(2+N)) * ((2+n)/(3+N)) * ((3+n)/(4+N)) ) + UN <- c( RN[1]*TN[1], (RN[1]*TN[2] + (N-1)*RN[2]*TN[1]^2)/N, ( RN[1]*TN[3] + 3*(N-1)*RN[2]*TN[1]*TN[2] + (N-1)*(N-2)*RN[3]*TN[1]^3)/N^2 ) + UC <- c( 0, UN[2]-UN[1]^2, UN[3]-3*UN[1]*UN[2]+2*UN[1]^3 ) + + A <- (4*UC[2]^3/UC[3]^2) + B <- (0.5*UC[3]/UC[2]) + G <- (UN[1]-2*UC[2]^2/UC[3]) + Z <- qnorm(confidence.level) + CB <- G + A*B*(1+Z/sqrt(9*A)-1/(9*A))^3 + ifelse(mult == 0, CB*100, (1 + CB) * (mult)) +} + +MUS.binomial.bound <- function(x, scope="qty", as.pct=FALSE, include.high.values=TRUE, confidence.level=0.95) { + if (!class(x)=="MUS.evaluation.result" && !is.vector(x)) stop("x has to be a vector or an object of type MUS.evaluation.result. Use function MUS.evaluate to create such an object.") + if (class(x)=="MUS.evaluation.result") { + if (scope == "value") { + if (include.high.values && is.data.frame(x$filled.high.values) ) { + misstatement <- sum(x$filled.sample[,x$col.name.book.values] - x$filled.sample[,x$col.name.audit.values]) + + sum(x$filled.high.values[,x$col.name.book.values] - x$filled.high.values[,x$col.name.audit.values]) + audited.value <- sum(x$filled.sample[,x$col.name.book.values]) + sum(x$filled.high.values[,x$col.name.book.values]) + book.value <- length(x$filled.sample[,x$col.name.book.values]) + length(x$filled.high.values[,x$col.name.book.values]) + } else { + misstatement <- sum(x$filled.sample[,x$col.name.book.values] - x$filled.sample[,x$col.name.audit.values]) + audited.value <- sum(x$filled.sample[,x$col.name.book.values]) + book.value <- length(x$filled.sample[,x$col.name.book.values]) + } + misstatement <- ceiling(misstatement / audited.value * book.value ) + } else { + if (include.high.values && is.data.frame(x$filled.high.values) ) { + misstatement <- sum(x$filled.sample[,x$col.name.book.values] != x$filled.sample[,x$col.name.audit.values]) + + sum(x$filled.high.values[,x$col.name.book.values] != x$filled.high.values[,x$col.name.audit.values]) + book.value <- length(x$filled.sample[,x$col.name.book.values]) + length(x$filled.high.values[,x$col.name.book.values]) + } else { + misstatement <- sum(x$filled.sample[,x$col.name.book.values] != x$filled.sample[,x$col.name.audit.values]) + book.value <- length(x$filled.sample[,x$col.name.book.values]) + } + } + materiality <- x$tolerable.error / x$book.value + confidence.level = x$confidence.level + mult <- ifelse(as.pct, 100, x$book.value) + } else { + # x are taintings + mult <- 100 + book.value <- length(x) + misstatement <- sum(x) + } + + if (requireNamespace("DescTools", quietly = TRUE)) { + bc <- DescTools::BinomCI(misstatement, book.value, conf.level=1-(1-confidence.level) * 2, method = "clopper-pearson") + ifelse(as.pct, (bc[3] * mult), round(bc[3] * mult)) + } else { + message("MUS.binomial.bound requires package DescTools.") + NULL + } +} + +MUS.multinomial.bound <- function(x, as.pct=FALSE, include.high.values=TRUE) { + if (class(x)!="MUS.evaluation.result") stop("x has to be an object from type MUS.evaluation.result. Use function MUS.evaluate to create such an object.") + res <- NA + if (requireNamespace("DescTools", quietly = TRUE)) { + if (include.high.values && is.data.frame(x$filled.high.values) ) { + misstatement <- ceiling(c(1 - x$filled.sample[,x$col.name.audit.values] / x$filled.sample[,x$col.name.book.values], + 1 - x$filled.high.values[,x$col.name.audit.values] / x$filled.high.values[,x$col.name.book.values])) + } else { + misstatement <- ceiling(c(1 - x$filled.sample[,x$col.name.audit.values] / x$filled.sample[,x$col.name.book.values])) + } + + observed <- aggregate(data.frame(count = misstatement), list(value = misstatement), length) + res <- DescTools::MultinomCI(observed$count, conf.level=1-(1-x$confidence.level) * 2, method="sisonglaz") + mult <- ifelse(as.pct, 100, x$book.value) + ifelse(as.pct, ((1-res[observed$value==0][2])) * mult, round(((1-res[observed$value==0][2])) * mult)) + } else { + message("MUS.multinomial.bound requires package DescTools.") + NULL + } +} + +MUS.combined.high.error.rate <- function(evaluation, interval.type="one-sided"){ + filled.sample <- evaluation$filled.sample + filled.high.values <- evaluation$filled.high.values + col.name.audit.values <- evaluation$col.name.audit.values + col.name.book.values <- evaluation$col.name.book.values + confidence.level <- evaluation$confidence.level + + ratios <- 1 - filled.sample[,col.name.audit.values]/filled.sample[,col.name.book.values] + qty_errors <- sum(ratios!=0) + ratios_mean <- mean(ratios) + ratios_sd <- sd(ratios) + if (is.data.frame(filled.high.values)) { + N <- nrow(evaluation$data) - nrow(filled.high.values) + Y <- sum(evaluation$data[, col.name.book.values]) - sum(filled.high.values[, col.name.book.values]) + high.values.error <- sum(filled.high.values[, col.name.book.values]-filled.high.values[, col.name.audit.values]) + } else { + N <- nrow(evaluation$data) + Y <- sum(evaluation$data[, col.name.book.values]) + high.values.error <- 0 + } + R <- ifelse(interval.type == "two-sided", 1 - (1 - confidence.level) / 2, confidence.level) + U <- qt(R, qty_errors - 1) + + most.likely.error <- ratios_mean * Y + precision <- U * Y * ratios_sd / sqrt(nrow(filled.sample)) + upper.error.limit <- most.likely.error + precision * sign(most.likely.error) + high.values.error + upper.error.limit +} diff --git a/R/MUS.combine.R b/R/MUS.combine.R new file mode 100644 index 0000000..62b20a6 --- /dev/null +++ b/R/MUS.combine.R @@ -0,0 +1,131 @@ +MUS.combine <- function(object.list) { + if (!is.list(object.list) || length(object.list)<1) { + stop("object.list must be a list with one or more MUS.evaluation.result objects.") + } + s <- 1 + x <- object.list[[s]] + if (length(object.list)>1) { + x$High.value.threshold <- "-" + x$Strata <- length(object.list) + x$qty.rejected <- ifelse(x$acceptable, 0, 1) + x$qty.accepted <- ifelse(x$acceptable, 1, 0) + for (s in 2:length(object.list)) { + y <- object.list[[s]] + x$data <- rbind(x$data, y$data) + x$sample <- rbind(x$sample, y$sample) + if ("filled.sample" %in% names(x)) { + x$filled.sample <- rbind(x$filled.sample, y$filled.sample) + } + if ("high.values" %in% names(x) && class(y$high.values)=="data.frame") { + if (class(x$high.values)=="data.frame") { + x$high.values <- rbind(x$high.values, y$high.values) + } else { + x$high.values <- y$high.values + } + } + if ("filled.high.values" %in% names(x) && class(y$filled.high.values)=="data.frame") { + if (class(x$filled.high.values)=="data.frame") { + x$filled.high.values <- rbind(x$filled.high.values, y$filled.high.values) + } else { + x$filled.high.values <- y$filled.high.values + } + } + if ("sample.population" %in% names(x)) { + x$sample.population <- rbind(x$sample.population, y$sample.population) + } + if ("Results.Total" %in% names(x)) { + for (j in 1:2) { + x$Results.Total$Number.of.Errors[j] <- + x$Results.Total$Number.of.Errors[j] + + y$Results.Total$Number.of.Errors[j] + + x$Results.Total$Net.upper.error.limit[j] <- + x$Results.Total$Net.upper.error.limit[j] + + y$Results.Total$Net.upper.error.limit[j] + + x$Results.Total$Gross.upper.error.limit[j] <- + x$Results.Total$Gross.upper.error.limit[j] + + y$Results.Total$Gross.upper.error.limit[j] + + x$Results.Sample$Number.of.Errors[j] <- + x$Results.Sample$Number.of.Errors[j] + + y$Results.Sample$Number.of.Errors[j] + + x$Results.Sample$Net.upper.error.limit[j] <- + x$Results.Sample$Net.upper.error.limit[j] + + y$Results.Sample$Net.upper.error.limit[j] + + x$Results.Sample$Gross.upper.error.limit[j] <- + x$Results.Sample$Gross.upper.error.limit[j] + + y$Results.Sample$Gross.upper.error.limit[j] + + x$Results.High.values$Number.of.Errors[j] <- + x$Results.High.values$Number.of.Errors[j] + + y$Results.High.values$Number.of.Errors[j] + + x$Results.High.values$Gross.Value.of.Errors[j] <- + x$Results.High.values$Gross.Value.of.Errors[j] + + y$Results.High.values$Gross.Value.of.Errors[j] + + x$Results.Sample$Precision.Gap.widening[j] <- + x$Results.Sample$Precision.Gap.widening[j] + + y$Results.Sample$Precision.Gap.widening[j] + + x$Results.Sample$Total.Precision[j] <- + x$Results.Sample$Total.Precision[j] + + y$Results.Sample$Total.Precision[j] + + x$Results.Total$Net.most.likely.error[j] <- + x$Results.Total$Net.most.likely.error[j] + + y$Results.Total$Net.most.likely.error[j] + } + + x$Results.Total$Total.number.of.items.examined <- + x$Results.Total$Total.number.of.items.examined + + y$Results.Total$Total.number.of.items.examined + + x$Results.Sample$Sample.Size <- + x$Results.Sample$Sample.Size + + y$Results.Sample$Sample.Size + + x$Results.Sample$Basic.Precision <- + x$Results.Sample$Basic.Precision + + y$Results.Sample$Basic.Precision + + x$Results.High.values$Number.of.high.value.items <- + x$Results.High.values$Number.of.high.value.items + + y$Results.High.values$Number.of.high.value.items + + x$Results.High.values$Net.Value.of.Errors <- + x$Results.High.values$Net.Value.of.Errors + + y$Results.High.values$Net.Value.of.Errors + + x$UEL.low.error.rate <- x$UEL.low.error.rate + y$UEL.low.error.rate + x$UEL.high.error.rate <- x$UEL.high.error.rate + y$UEL.high.error.rate + + if ("acceptable.low.error.rate" %in% names(x)) { + x$acceptable.low.error.rate <- + ifelse(y$acceptable.low.error.rate, x$acceptable.low.error.rate, y$acceptable.low.error.rate) + } + if ("acceptable.high.error.rate" %in% names(x)) { + x$acceptable.high.error.rate <- + ifelse(y$acceptable.high.error.rate, x$acceptable.high.error.rate, y$acceptable.high.error.rate) + } + if ("acceptable" %in% names(x)) { + x$acceptable <- ifelse(y$acceptable, x$acceptable, y$acceptable) + x$qty.rejected <- x$qty.rejected + ifelse(y$acceptable, 0, 1) + x$qty.accepted <- x$qty.accepted + ifelse(y$acceptable, 1, 0) + } + + } + + x$book.value <- x$book.value + y$book.value + x$tolerable.error <- x$tolerable.error + y$tolerable.error + x$expected.error <- x$expected.error + y$expected.error + x$n <- x$n + y$n + x$n.min <- x$n.min + y$n.min + } + x$combined <- TRUE + } + x +} diff --git a/R/MUS.evaluation.R b/R/MUS.evaluation.R index d92bd63..15ad47e 100644 --- a/R/MUS.evaluation.R +++ b/R/MUS.evaluation.R @@ -14,13 +14,18 @@ # create a table, based on the ideas of precision gap widening and cell evaluation -.MUS.precision.gap.widening.table <- function(ds, population.amount, confidence.level, filled.sample){ +.MUS.precision.gap.widening.table <- function(ds, idx, population.amount, confidence.level, filled.sample){ # UEL Factor = lambda = E(distribution) = Sample size * Errors in Population / Elements in population UEL.Factor <- round(sapply(0:length(ds), .calculate.m.hyper, sample.size=nrow(filled.sample), alpha=1-confidence.level, account.value=population.amount)*nrow(filled.sample)/population.amount, digits=4) average.ds <- round(cumsum(ds)/1:length(ds), digits=4) - + # create table - result.table <- data.frame(Error.Stage=0:length(ds), UEL.Factor=UEL.Factor, Tainting=c(1,ds), Average.Taintings=c(0,average.ds), UEL.previous.Stage=rep(0, times=length(UEL.Factor)), Load.and.Spread=rep(0, times=length(UEL.Factor)), Simple.Spread=c(UEL.Factor[1], rep(NA, times=length(UEL.Factor)-1)), Stage.UEL.max=c(UEL.Factor[1], rep(NA, times=length(UEL.Factor)-1))) + result.table <- data.frame(Error.Stage=0:length(ds), UEL.Factor=UEL.Factor, Tainting=c(1,ds), + Average.Taintings=c(0,average.ds), UEL.previous.Stage=rep(0, times=length(UEL.Factor)), + Load.and.Spread=rep(0, times=length(UEL.Factor)), Simple.Spread=c(UEL.Factor[1], rep(NA, times=length(UEL.Factor)-1)), + Stage.UEL.max=c(UEL.Factor[1], rep(NA, times=length(UEL.Factor)-1)), + sampling.interval=c(max(filled.sample$sampling.interval), filled.sample[idx, "sampling.interval"]) + ) if (length(ds)==0) return(result.table) # stop to prevent errors if no errors are found # fill last 4 columns (row by row, because the next row is dependent of values of the previous row) for (row in (1:length(ds))+1){ # for each Error.Stage, because first row with 0 taintings is always +1 @@ -33,7 +38,8 @@ } -MUS.evaluation <- function(extract, filled.sample, filled.high.values, col.name.audit.values="audit.value", col.name.riskweights=NULL){ +MUS.evaluation <- function(extract, filled.sample, filled.high.values, col.name.audit.values="audit.value", col.name.riskweights=NULL, + interval.type="one-sided", print.advice=TRUE, tainting.order="decreasing", experimental=FALSE, combined=FALSE){ # checking parameter extract, col.name.audit.values and col.name.riskweights if (class(extract)!="MUS.extraction.result") stop("extract has to be an object from type MUS.extraction.result. Use function MUS.extraction to create such an object.") if (!is.character(col.name.audit.values) | length(col.name.audit.values)!=1) stop("col.name.audit.values has to be a single character value (default book.value).") @@ -42,17 +48,19 @@ MUS.evaluation <- function(extract, filled.sample, filled.high.values, col.name. # if extracted sample has no elements (only high value items needs to be tested) do not evaluate and use zeros instead if (nrow(extract$sample)==0) { Results.Sample <- list( Sample.Size=0, - Number.of.Errors=c(overstatements=0, understatements=0), + Number.of.Errors=c(overstatements=0, understatements=0), Gross.most.likely.error=0, Net.most.likely.error=c(overstatements=0, understatements=0), Basic.Precision=0, Precision.Gap.widening=c(overstatements=0, understatements=0), Total.Precision=c(overstatements=0, understatements=0), Gross.upper.error.limit=c(overstatements=0, understatements=0), - Net.upper.error.limit=0) + Net.upper.error.limit=0, + Gross.Value.of.Errors=c(overstatements=0, understatements=0) + ) filled.sample <- "Not required because no sample items were selected during extraction" over <- "Not applicable because no sample items were selected during extraction" - under <- "Not applicable because no sample items were selected during extraction" + under <- "Not applicable because no sample items were selected during extraction" } else { # check parameters filled.sample in combination with col.name.book.values, col.name.audit.values and col.name.riskweights if (!is.data.frame(filled.sample) | is.matrix(filled.sample)) stop("filled.sample needs to be a data frame or a matrix but it is not.") @@ -64,45 +72,83 @@ MUS.evaluation <- function(extract, filled.sample, filled.high.values, col.name. population.amount <- sum(extract$sample.population[,extract$col.name.book.values]) # prevent Errors if column name will not be unique (a column d is used in over- and understatement evaluation) - if(is.element("d", names(filled.sample))) stop("filled.sample must not have a column 'd' because this column name is used for internal evaluation.") - + if(is.element("d", names(filled.sample))) stop("filled.sample must not have a column 'd' because this column name is used for internal evaluation.") + if(is.element("tord", names(filled.sample))) stop("filled.sample must not have a column 'tord' because this column name is used for internal evaluation.") + # add sampling interval to filled sample, in order to be able to calculate combined UEL + if(!is.element("sampling.interval", names(filled.sample))) { + filled.sample$sampling.interval = rep(extract$sampling.interval, times=nrow(filled.sample)) + } # calculate suitable d's und evaluation table - overstatements - ds <- cbind(filled.sample, d=1-filled.sample[,col.name.audit.values]/filled.sample[,extract$col.name.book.values]) # calculate d's and add to data frame + tmp <- 1-filled.sample[,col.name.audit.values]/filled.sample[,extract$col.name.book.values] + tord <- tmp + if (tainting.order=="increasing") { + tord <- 1-tmp + } + if (tainting.order=="absolute") { + tord <- filled.sample[,extract$col.name.book.values]-filled.sample[,col.name.audit.values] + } + if (tainting.order=="random") { + tord <- sample(tmp) + } + ds <- cbind(filled.sample, d=tmp, tord=tord) # calculate d's and add to data frame + + if(is.null(col.name.riskweights)) { + errors <- ds[,extract$col.name.book.values]-ds[,col.name.audit.values] + } else { + errors <- (ds[,extract$col.name.book.values]-ds[,col.name.audit.values])/ds[,col.name.riskweights] + # if risk weights are provided, also multiply with them + } + ds <- subset(ds, ds$d>0) # filter out all correct (and understatements which will be handled later) - ds <- ds[order(ds$d,decreasing=TRUE),] # sort d's descendend + ds <- ds[order(ds$tord, decreasing=TRUE),] # sort d's descendend + idx <- rownames(ds) if(is.null(col.name.riskweights)) { ds <- ds$d } else { ds <- ds$d/ds[,col.name.riskweights] # if risk weights are provided, also multiply with them } ds <- round(ds, digits=4) - over <- .MUS.precision.gap.widening.table(ds, population.amount, extract$confidence.level, filled.sample) # calculate table - + over <- .MUS.precision.gap.widening.table(ds, idx, population.amount, extract$confidence.level, filled.sample) # calculate table + # calculate suitable d's und evaluation table - understatements - ds <- cbind(filled.sample, d=1-filled.sample[,col.name.audit.values]/filled.sample[,extract$col.name.book.values]) # calculate d's and add to data frame + tmp <- 1-filled.sample[,col.name.audit.values]/filled.sample[,extract$col.name.book.values] + tord <- tmp + if (tainting.order=="increasing") { + tord <- tmp + } + if (tainting.order=="absolute") { + tord <- filled.sample[,extract$col.name.book.values]-filled.sample[,col.name.audit.values] + } + if (tainting.order=="random") { + tord <- sample(tmp) + } + ds <- cbind(filled.sample, d=tmp, tord=tord) # calculate d's and add to data frame + ds <- subset(ds, ds$d<0) # filter out all correct (and overstatements which was handled before) - ds <- ds[order(ds$d,decreasing=FALSE),] # sort d's ascendend + ds <- ds[order(ds$tord, decreasing=FALSE),] # sort d's ascendend + idx <- rownames(ds) if(is.null(col.name.riskweights)) { ds <- -ds$d } else { ds <- -ds$d/ds[,col.name.riskweights] # if risk weights are provided, also multiply with them } ds <- round(ds, digits=4) - under <- .MUS.precision.gap.widening.table(ds, population.amount, extract$confidence.level, filled.sample) # calculate table - + under <- .MUS.precision.gap.widening.table(ds, idx, population.amount, extract$confidence.level, filled.sample) # calculate table # calculate results table Gross.most.likely.error=c(overstatements=(sum(over$Tainting)-1), understatements=(sum(under$Tainting)-1))*extract$sampling.interval # also required as intermediate step for later calculations Gross.upper.error.limit=c(overstatements=max(over$Stage.UEL.max), understatements=max(under$Stage.UEL.max))*extract$sampling.interval # also required as intermediate step for later calculations Basic.Precision=.calculate.m.hyper(0, sample.size=nrow(filled.sample), alpha=1-extract$confidence.level, account.value=population.amount) # also required as intermediate step for later calculations - Results.Sample <- list( Sample.Size=nrow(filled.sample), - Number.of.Errors=c(overstatements=max(over$Error.Stage), understatements=max(under$Error.Stage)), + Results.Sample <- list( Sample.Size=nrow(filled.sample), + Number.of.Errors=c(overstatements=max(over$Error.Stage), understatements=max(under$Error.Stage)), Gross.most.likely.error=Gross.most.likely.error, Net.most.likely.error=c(overstatements=1, understatements=-1)*sum(Gross.most.likely.error*c(1,-1)), Basic.Precision=Basic.Precision, Precision.Gap.widening=Gross.upper.error.limit-Gross.most.likely.error-Basic.Precision, # values that are not zero came from rounding Total.Precision=Gross.upper.error.limit-Gross.most.likely.error, Gross.upper.error.limit=Gross.upper.error.limit, - Net.upper.error.limit=Gross.upper.error.limit-Gross.most.likely.error+c(overstatements=1, understatements=-1)*sum(Gross.most.likely.error*c(1,-1))) + Net.upper.error.limit=Gross.upper.error.limit-Gross.most.likely.error+c(overstatements=1, understatements=-1)*sum(Gross.most.likely.error*c(1,-1)), + Gross.Value.of.Errors=c(overstatements=sum(subset(errors, errors>0)), understatements=sum(subset(errors, errors<0))) + ) } # if extracted high items have no elements (only sample items needs to be tested) do not evaluate and use zeros instead @@ -121,9 +167,7 @@ MUS.evaluation <- function(extract, filled.sample, filled.high.values, col.name. if (!is.element(col.name.audit.values, names(filled.high.values))) stop("The filled.high.values requires a column with the audit values and the name of this column has to be provided by parameter col.name.audit.values (default audit.value).") if (!is.null(col.name.riskweights)) if (!is.element(col.name.riskweights, names(filled.high.values))) stop("If col.name.riskweights is not NULL, the filled.high.values requires a column with the col.name.riskweights and the name of this column has to be provided by parameter col.name.riskweights (default NULL).") - # evaluate high value items - errors <- filled.high.values[,extract$col.name.book.values]-filled.high.values[,col.name.audit.values] if(is.null(col.name.riskweights)) { errors <- filled.high.values[,extract$col.name.book.values]-filled.high.values[,col.name.audit.values] } else { @@ -134,25 +178,72 @@ MUS.evaluation <- function(extract, filled.sample, filled.high.values, col.name. Gross.Value.of.Errors=c(overstatements=sum(subset(errors, errors>0)), understatements=sum(subset(errors, errors<0))), Net.Value.of.Errors=sum(errors)) } - + # evaluate sample and high values combined - Results.Total <- list( Total.number.of.items.examined=Results.Sample$Sample.Size+Results.High.values$Number.of.high.value.items, - Number.of.Errors=Results.Sample$Number.of.Errors+Results.High.values$Number.of.Errors, + Results.Total <- list( Total.number.of.items.examined=Results.Sample$Sample.Size+Results.High.values$Number.of.high.value.items, + Number.of.Errors=Results.Sample$Number.of.Errors+Results.High.values$Number.of.Errors, Gross.most.likely.error=Results.Sample$Gross.most.likely.error+Results.High.values$Gross.Value.of.Errors, + Gross.Value.of.Errors=Results.Sample$Gross.Value.of.Errors+Results.High.values$Gross.Value.of.Errors, Net.most.likely.error=c(overstatements=1, understatements=-1)*sum(Results.Sample$Gross.most.likely.error)+Results.High.values$Net.Value.of.Errors*c(1,-1), Gross.upper.error.limit=Results.Sample$Gross.upper.error.limit+Results.High.values$Gross.Value.of.Errors, - Net.upper.error.limit=Results.Sample$Gross.upper.error.limit-Results.Sample$Gross.most.likely.error+c(overstatements=1, understatements=-1)*sum(Results.Sample$Gross.most.likely.error*c(1,-1))+Results.High.values$Net.Value.of.Errors*c(1,-1)) + Net.upper.error.limit=Results.Sample$Gross.upper.error.limit-Results.Sample$Gross.most.likely.error+c(overstatements=1, understatements=-1)*sum(Results.Sample$Gross.most.likely.error*c(1,-1))+Results.High.values$Net.Value.of.Errors*c(1,-1) + ) # extract a final statement if population is acceptable (provided the confidence level) - acceptable <- max(Results.Total$Net.upper.error.limit*c(1,-1))=20) { - warning("You had at least 20 errors in the sample - some statistical software recommends High Error Rate evaluation instead of Low Error Rate evaluation in this case. However, High Error Rate evaluation is not yet implemented. The evaluation might not be appropriate.") + MLE.low.error.rate <- Results.Total$Net.most.likely.error[1] + MLE.high.error.rate <- high.error.rate$most.likely.error + MLE.final <- MLE.low.error.rate + if (max(Results.Sample$Number.of.Errors) >= 20) { + if (print.advice) { + message("\n** ", "You had at least 20 errors in the sample. High Error Rate evaluation recommended.") + } + acceptable <- acceptable.high.error.rate + MLE.final <- MLE.high.error.rate } # return all results and parameters - result <- c(extract, list(filled.sample=filled.sample, filled.high.values=filled.high.values, col.name.audit.values=col.name.audit.values, Overstatements.Result.Details=over, Understatements.Result.Details=under, Results.Sample=Results.Sample, Results.High.values=Results.High.values, Results.Total=Results.Total, acceptable=acceptable)) + result <- c(extract, list(filled.sample=filled.sample, filled.high.values=filled.high.values, col.name.audit.values=col.name.audit.values, Overstatements.Result.Details=over, Understatements.Result.Details=under, Results.Sample=Results.Sample, Results.High.values=Results.High.values, Results.Total=Results.Total, acceptable=acceptable, tainting.order=tainting.order, + UEL.low.error.rate=UEL.low.error.rate, UEL.high.error.rate=UEL.high.error.rate, + MLE.low.error.rate=MLE.low.error.rate, MLE.high.error.rate=MLE.high.error.rate, MLE.final=MLE.final, + acceptable.low.error.rate=acceptable.low.error.rate, acceptable.high.error.rate=acceptable.high.error.rate, + high.error.rate=high.error.rate, combined=combined)) class(result) <- "MUS.evaluation.result" + if (experimental) { + result$moment.bound <- MUS.moment.bound(result) + result$acceptable.moment.bound <- (result$moment.bound <= extract$tolerable.error) + result$binomial.bound <- MUS.binomial.bound(result) + result$acceptable.binomial.bound <- (result$binomial.bound <= extract$tolerable.error) + result$multinomial.bound <- MUS.multinomial.bound(result) + result$acceptable.multinomial.bound <- (result$multinomial.bound <= extract$tolerable.error) + } return(result) } diff --git a/R/MUS.extend.R b/R/MUS.extend.R new file mode 100644 index 0000000..e4d5ba0 --- /dev/null +++ b/R/MUS.extend.R @@ -0,0 +1,91 @@ + +MUS.extend <- function(extract, new_plan=NULL, additional.n=NULL) { + if (class(extract)!="MUS.extraction.result") stop("extract has to be an object from type MUS.extraction.result. Use function MUS.extraction to create such an object.") + if (class(new_plan)!="MUS.planning.result" && !is.null(new_plan)) stop("new_plan has to be an object from type MUS.planning.result. Use function MUS.planning to create such an + object or NULL.") + if (class(additional.n)!="numeric" && !is.null(additional.n)) stop("additional.n must be numeric or NULL.") + # rebuild plan from extract object + if (is.null(additional.n)) { + additional.n <- 0 + } + + if (is.null(new_plan)) { + n.final = extract$n + additional.n + interval <- extract$book.value / n.final # calculate sampling interval + tol.taint <- extract$expected.error / extract$book.value * n.final # calculate tolerable taintings (maximal number of full overstatements that will be acceptable in the sample) + + new_plan <- list( + data=extract$data, + col.name.book.values=extract$col.name.book.values, + confidence.level=extract$confidence.level, + tolerable.error=extract$tolerable.error, + expected.error=extract$expected.error, + book.value=extract$book.value, + n=n.final, + High.value.threshold=interval, + tolerable.taintings=tol.taint, + combined=extract$combined) + class(new_plan) <- "MUS.planning.result" + } else { + additional.n <- new_plan$n - extract$n + } + if (additional.n < 1) { + extract$additional.sample <- extract$sample[FALSE, ] + return(extract) + } + total.n <- (additional.n + extract$n) + colunas <- colnames(extract$sample.population) + sample.cols <- colnames(extract$sample) + + # split data into high values and population from which will be sampled + if (is.data.frame(extract$high.values)) { + old.high.values <- extract$high.values + } else { + old.high.values <- extract$sample.population[FALSE, ] + } + old.high.values$MUS.total <- rep(0, nrow(old.high.values)) + old.high.values$MUS.hit <- rep(0, nrow(old.high.values)) + # old.sample.population <- extract$sample.population + old.sample <- extract$sample + old.audited <- rbind(old.sample[, sample.cols], old.high.values[, sample.cols]) + # create a brand new sample with the new n + new_extract <- MUS.extraction(new_plan, start.point=NULL, extract$seed, extract$obey.n.as.min, extract$combined) + if (is.data.frame(new_extract$high.values)) { + new.high.values <- new_extract$high.values + } else { + new.high.values <- new_extract$sample.population[FALSE, ] + } + new.high.values$MUS.total <- rep(0, nrow(new.high.values)) + new.high.values$MUS.hit <- rep(0, nrow(new.high.values)) + + new.sample <- rownames(new_extract$sample) + new.n <- length(new.sample) + selected <- rownames(old.audited)[!rownames(old.audited) %in% rownames(new.high.values)] + new.basedraw <- new.sample[!new.sample %in% selected] + # final sample is original sample+high.values that are not on the new high.values + # extended by randomly selected elements from the new sample + # this allows us to reuse the extraction method as is + newSize <- pmax(0, new.n - length(selected)) + if (newSize > 0) { + adding <- sample(new.basedraw, newSize) + final.sample <- c(selected, adding) + } else { + final.sample <- c(selected) + adding <- c() + } + + if(!"MUS.total" %in% colnames(new_extract$sample.population)) { + new_extract$sample.population$MUS.total <- rep(0, nrow(new_extract$sample.population)) + } + if(!"MUS.hit" %in% colnames(new_extract$sample.population )) { + new_extract$sample.population$MUS.hit <- rep(0, nrow(new_extract$sample.population)) + } + new_extract$sample <- new_extract$sample.population[rownames(new_extract$sample.population) %in% final.sample, sample.cols] + new_extract$sample.population <- new_extract$sample.population[, colunas] + # calculate revised sampling interval (used for evaluation of the sample population) + new_extract$interval <- sum(new_extract$sample.population[,new_extract$col.name.book.values])/nrow(new_extract$sample) + new_extract$extensions <- extract$extensions + 1 + new_extract$n.qty <- c(extract$n.qty, additional.n) + # return all results, parameters and planning object as list for further processing + return(new_extract) +} diff --git a/R/MUS.extraction.R b/R/MUS.extraction.R index 3e8e7c7..28da1a9 100644 --- a/R/MUS.extraction.R +++ b/R/MUS.extraction.R @@ -1,4 +1,4 @@ -MUS.extraction <- function(plan, start.point=NULL, seed=NULL, obey.n.as.min=FALSE){ +MUS.extraction <- function(plan, start.point=NULL, seed=NULL, obey.n.as.min=FALSE, combined=FALSE){ # check parameters plan, seed and obey.n.as.min if (class(plan)!="MUS.planning.result") stop("plan has to be an object from type MUS.planning.result. Use function MUS.planning to create such an object.") if (!is.null(seed)) if(!is.numeric(seed) | round(seed)!=seed | length(seed)!=1 | seed<0) stop("seed has to be an integer value greater or equal than 0.") @@ -6,7 +6,7 @@ MUS.extraction <- function(plan, start.point=NULL, seed=NULL, obey.n.as.min=FALS # set seed according to user input if (!is.null(seed)) set.seed(seed) - + # split data into high values and population from which will be sampled high.values <- subset(plan$data, with(plan$data, get(plan$col.name.book.values))>=plan$High.value.threshold) sample.population <- subset(plan$data, with(plan$data, get(plan$col.name.book.values))=plan$High.value.threshold) - sample.population <- subset(plan$data, with(plan$data, get(plan$col.name.book.values))=interval) + sample.population <- subset(plan$data, with(plan$data, get(plan$col.name.book.values))= 1 || pct.ratio < 0 || pct.ratio >= 1) { + stop("Parameters must be between 0 and 1.") + } else { + F = qgamma(confidence.level, 1, 1) + if (pct.ratio == 0) { + resp = F + } else { + F1 = 0 + i = 0 + while ((abs(F1-F)>solved) && (i<=max_iter)) { + F1 = F + F = qgamma(confidence.level, 1 + pct.ratio * F1, 1) + i = i + 1 + } + resp = ifelse((abs(F1-F)<=solved), F, erro) + } + } + resp } +MUS.calc.n.conservative <- function(confidence.level, tolerable.error, expected.error, book.value) { +# calculate n consevatively, as per AICPA audit guide + pct.ratio = expected.error / tolerable.error + conf.factor = ceiling(MUS.factor(confidence.level, pct.ratio)*100)/100 + ceiling(conf.factor / tolerable.error * book.value) +} -MUS.planning <- function(data, col.name.book.values="book.value", confidence.level=.95, tolerable.error, expected.error, n.min=0){ +MUS.planning <- function(data, col.name.book.values="book.value", confidence.level=.95, tolerable.error, expected.error, + n.min=0, errors.as.pct=FALSE, conservative=FALSE, combined=FALSE){ # check parameters data and col.name.book.values if (!is.data.frame(data) | is.matrix(data)) stop("Data needs to be a data frame or a matrix but it is not.") if (!is.character(col.name.book.values) | length(col.name.book.values)!=1 | !is.element(col.name.book.values, names(data))) stop("The data frame requires at least a column with the book values and the name of this column has to be provided by parameter col.name.book.values (default book.value).") @@ -29,16 +67,23 @@ MUS.planning <- function(data, col.name.book.values="book.value", confidence.lev # calculate gross book value from dataset book.value <- sum(pmax(with(data, get(col.name.book.values)), 0)) - + # calculate number of items in the dataset num.items <- length(with(data, get(col.name.book.values))) # check other parameters + if (errors.as.pct && is.numeric(tolerable.error) && is.numeric(expected.error)) { + tolerable.error = tolerable.error * book.value; + expected.error = expected.error * book.value; + } if (!is.numeric(confidence.level) | length(confidence.level)!=1 | confidence.level<=0 | confidence.level>=1) stop("Confidence level has to be a numeric value between 0 and 1 (both exclusive).") if (!is.numeric(tolerable.error) | length(tolerable.error)!=1 | tolerable.error<=0) stop("Tolerable Error has to be a numeric value between 0 and book value (both exclusive).") if (!is.numeric(expected.error) | length(expected.error)!=1 | expected.error<0) stop("Expected error has to be a numeric value greater or equal to 0.") if (!is.numeric(n.min) | length(n.min)!=1 | n.min<0 | n.min>=num.items) stop("Minimum number of sample size has to be a numeric value between 0 and the number of items in the population (last exclusive). If the minimum sample size is equal or larger than the number of items in the population, sampling is not suitable because every item has to be tested anyway.") - + too.large <- (tolerable.error/book.value)*(1-confidence.level)*sqrt(tolerable.error-expected.error) < 0.07 + if (too.large) { + warning("Combination of parameters leads to impractically large sample.") + } if (tolerable.error>=book.value) { warning("Tolerable Error has to be a numeric value between 0 and book value (both exclusive). If the tolerable error is equal larger than book value, no sampling is necessary. However, Planning will be proceeded.") n.optimal <- 0 @@ -68,11 +113,16 @@ MUS.planning <- function(data, col.name.book.values="book.value", confidence.lev } } n.final <- max(n.optimal, n.min) # take greater value of optimal n or predefined minimum sample size + + if (conservative) { + n.final = max(n.final, MUS.calc.n.conservative(confidence.level, tolerable.error, expected.error, book.value)) + } + interval <- book.value/n.final # calculate sampling interval tol.taint <- expected.error/book.value*n.final # calculate tolerable taintings (maximal number of full overstatements that will be acceptable in the sample) # return all results, parameters and data as list for further processing - result <- list(data=data, col.name.book.values=col.name.book.values, confidence.level=confidence.level, tolerable.error=tolerable.error, expected.error=expected.error, book.value=book.value, n=n.final, High.value.threshold=interval, tolerable.taintings=tol.taint) + result <- list(data=data, col.name.book.values=col.name.book.values, confidence.level=confidence.level, tolerable.error=tolerable.error, expected.error=expected.error, book.value=book.value, n=n.final, High.value.threshold=interval, tolerable.taintings=tol.taint, combined=combined) class(result) <- "MUS.planning.result" return(result) } diff --git a/R/print.MUS.evaluation.result.R b/R/print.MUS.evaluation.result.R index e0907a7..712f0fc 100644 --- a/R/print.MUS.evaluation.result.R +++ b/R/print.MUS.evaluation.result.R @@ -1,45 +1,160 @@ -print.MUS.evaluation.result <- function(x, ...){ +print.MUS.evaluation.result <- function(x, error.rate="auto", + print.misstatements=TRUE, print.planning=FALSE, print.extraction=FALSE, print.error.as.pct=TRUE, print.advice=TRUE, + style="default", use.pander=FALSE, ...){ # Checking parameter + dm <- "R-MUS" + bindtextdomain(dm) if (class(x)!="MUS.evaluation.result") stop("x has to be an object from type MUS.evaluation.result. Use function MUS.evaluate to create such an object.") - - cat("MONETARY UNIT SAMPLING\n\n") - if(x$acceptable) { - cat(strwrap("The sample provides a reasonable basis to conclude that the population is free of material misstatements (given the parameters below)."), sep="\n") - } else { - cat(strwrap("The sample provides NO reasonable basis to conclude that the population is free of material misstatements (given the parameters below). You have to get further audit evidence or extend the sample (currently not supported by this package)."), sep="\n") + x$error.as.pct <- print.error.as.pct + .title(gettext("Evaluation Results", domain=dm), use.pander=use.pander) + res <- list() + if (print.extraction) { + print.MUS.extraction.result(x, print.planning=print.planning, use.pander=use.pander) } - cat("\n") - cat(strwrap(paste0("The conclusion is based on a calculated Upper Error Limit of ", - round(x$Results.Total$Net.upper.error.limit["overstatements"]), - " for overstatements and ", - round(x$Results.Total$Net.upper.error.limit["understatements"]), - " for understatements (please be aware that MUS is not designed to detect understatements, thus they can only be used as an indicator).")), sep="\n") - - cat("\nMost important parameters:\n- Confidence Level:\t\t\t\t") - cat(x$confidence.level) - cat("\n- Tolerable Error (Materiality):\t\t") - cat(x$tolerable.error) - cat("\n- Population gross value:\t\t\t") - cat(x$book.value) - cat("\n- Expected Error in population:\t\t\t") - cat(x$expected.error) - cat("\n- Sample size:\t\t\t\t\t") - cat(x$Results.Total$Total.number.of.items.examined) - cat("\n- Threshold for individual significant items:\t") - cat(round(x$High.value.threshold)) - - cat("\n\nProjected Misstatement:\n") if(sum(x$Results.Total$Number.of.Errors)==0) { - cat("No misstatements found. Thus, the projected misstatememt is 0.\n") + cat("\n-", gettext("No misstatements found. Thus, the projected misstatememt is 0.", domain=dm)) } else { - cat(strwrap(paste0("Based on ", - x$Results.Total$Number.of.Errors["overstatements"], - " overstatement differences and ", - x$Results.Total$Number.of.Errors["understatements"], - " understatement differences the netted Most Likely Error is ", - round(x$Results.Total$Net.most.likely.error[1]), - " Monetary Units. You have to book the MLE if it is material.")), sep="\n") - cat("\nFactual Misstatements:\n") + sample.misstatements <- x$filled.sample[,x$col.name.book.values] - x$filled.sample[,x$col.name.audit.values] + res$sample.book.value <- sum(x$filled.sample[,x$col.name.book.values]) + res$audited.over.qty <- x$Results.Total$Number.of.Errors["overstatements"] + res$audited.under.qty <- x$Results.Total$Number.of.Errors["understatements"] + res$sample.over.qty <- x$Results.Sample$Number.of.Errors["overstatements"] + res$sample.under.qty <- x$Results.Sample$Number.of.Errors["understatements"] + + res$sample.over.value <- sum(sample.misstatements[sample.misstatements>0]) + res$sample.under.value <- sum(sample.misstatements[sample.misstatements<0]) + res$sample.over.rate <- .percent(res$sample.over.value / res$sample.book.value) + res$sample.under.rate <- .percent(res$sample.under.value / res$sample.book.value) + + res$audited.over.uel <- x$Results.Total$Net.upper.error.limit["overstatements"] + res$audited.under.uel <- x$Results.Total$Net.upper.error.limit["understatements"] + res$sample.over.uel <- x$Results.Sample$Net.upper.error.limit["overstatements"] + res$sample.under.uel <- x$Results.Sample$Net.upper.error.limit["understatements"] + + res$sample.miss.qty <- max(x$Results.Sample$Number.of.Errors) + res$sample.miss.value <- sum(sample.misstatements) + res$sample.miss.rate <- .percent(res$sample.miss.value/res$sample.book.value) + population.value <- x$book.value + if (class(x$filled.high.values)=="data.frame") { + high.misstatements <- x$filled.high.values[,x$col.name.book.values] - x$filled.high.values[,x$col.name.audit.values] + res$high.book.value <- sum(x$filled.high.values[,x$col.name.book.values]) + res$high.miss.qty <- sum(high.misstatements != 0) + res$high.miss.value <- sum(high.misstatements) + #population.value <- x$book.value - sum(x$filled.high.values[,x$col.name.book.values]) + res$high.over.value <- sum(high.misstatements[high.misstatements>0]) + res$high.under.value <- sum(high.misstatements[high.misstatements<0]) + res$high.over.qty <- x$Results.High.values$Number.of.Errors["overstatements"] + res$high.under.qty <- x$Results.High.values$Number.of.Errors["understatements"] + res$audited.over.value <- res$sample.over.value + res$high.over.value + res$audited.under.value <- res$sample.under.value + res$high.under.value + } else { + #population.value <- x$book.value + res$high.book.value <- 0 + res$high.miss.qty <- 0 + res$high.miss.value <- 0 + res$audited.over.value <- res$sample.over.value + res$audited.under.value <- res$sample.under.value + } + res$audited.miss.qty <- res$sample.miss.qty + res$high.miss.qty + res$audited.miss.value <- res$sample.miss.value + res$high.miss.value + res$audited.book.value <- res$sample.book.value + res$high.book.value + res$audited.over.rate <- .percent(res$audited.over.value / res$audited.book.value) + res$audited.under.rate <- .percent(res$audited.under.value / res$audited.book.value) + + res$high.miss.rate <- ifelse(res$high.book.value>0, .percent(res$high.miss.value/res$high.book.value), "-") + res$audited.miss.rate <- .percent(res$audited.miss.value/res$audited.book.value) + res$most.likely.error.value <- x$Results.Total$Net.most.likely.error[1] + res$most.likely.error.rate <- .percent(res$most.likely.error.value / population.value) + res$tainting.order <- x$tainting.order + res$UEL.lowrate.value <- x$UEL.low.error.rate + res$UEL.lowrate.rate <- .percent(res$UEL.lowrate.value / population.value) + res$UEL.highrate.value <- x$UEL.high.error.rate + res$UEL.highrate.rate <- .percent(res$UEL.highrate.value / population.value) + + res$MLE.lowrate.value <- x$MLE.low.error.rate + res$MLE.lowrate.rate <- .percent(res$MLE.lowrate.value / population.value) + res$MLE.highrate.value <- x$MLE.high.error.rate + res$MLE.highrate.rate <- .percent(res$MLE.highrate.value / population.value) + res$MLE.final.value <- x$MLE.final + res$MLE.final.rate <- .percent(res$MLE.final.value / population.value) + res$MLE.observed.value <- res$audited.miss.value + res$MLE.observed.rate <- .percent(res$MLE.observed.value / population.value) + res$MLE.estimated.value <- res$MLE.final.value - res$MLE.observed.value + res$MLE.estimated.rate <- .percent(res$MLE.estimated.value / population.value) + res$MLE.projection.rate <- .percent((res$MLE.final.value - res$audited.miss.value) / (population.value - res$audited.book.value)) + + tbl <- matrix(nrow=12, ncol=4) + tbl[1,] = c(gettext("Audited Misstatements", domain=dm), res$audited.miss.qty , .value(res$audited.miss.value), res$audited.miss.rate) + tbl[2,] = c(gettext("Audited Overstatements", domain=dm), res$audited.over.qty , .value(res$audited.over.value), res$audited.over.rate) + tbl[3,] = c(gettext("Audited Understatements", domain=dm), res$audited.under.qty , .value(res$audited.under.value), res$audited.under.rate) + tbl[4,] = c(gettext("Sample Misstatements", domain=dm), res$sample.miss.qty , .value(res$sample.miss.value), res$sample.miss.rate) + tbl[5,] = c(gettext("High Value Misstatements", domain=dm), res$high.miss.qty , .value(res$high.miss.value), res$high.miss.rate) + tbl[7,] = c(gettext("UEL (Low Error Rate)", domain=dm), "-" , .value(res$UEL.lowrate.value), res$UEL.lowrate.rate) + tbl[8,] = c(gettext("UEL (High Error Rate)", domain=dm), "-" , .value(res$UEL.highrate.value), res$UEL.highrate.rate) + if (res$sample.miss.qty > 20) { + tbl[6,] = c(gettext("Upper Error Limit (Final)", domain=dm), "-" , .value(res$UEL.highrate.value), res$UEL.highrate.rate) + } else { + tbl[6,] = c(gettext("Upper Error Limit (Final)", domain=dm), "-" , .value(res$UEL.lowrate.value), res$UEL.lowrate.rate) + } +# tbl[9,] = c(gettext("Most Likely Error", domain=dm), "-" , .value(res$most.likely.error.value), res$most.likely.error.rate) + tbl[9,] = c(gettext("Most Likely Error", domain=dm), "-" , .value(res$MLE.final.value), res$MLE.final.rate) + tbl[10,] = c(gettext("MLE (Observed)", domain=dm), "-" , .value(res$MLE.observed.value), res$MLE.observed.rate) + tbl[11,] = c(gettext("MLE (Projected)", domain=dm), "-" , .value(res$MLE.estimated.value), res$MLE.estimated.rate) + tbl[12,] = c(gettext("MLE (Projection Rate)", domain=dm), "-" , "-", res$MLE.projection.rate) + +# tbl[10,] = c(gettext("MLE (Low Error Rate)", domain=dm), "-" , .value(res$MLE.lowrate.value), res$MLE.lowrate.rate) +# tbl[11,] = c(gettext("MLE (High Error Rate)", domain=dm), "-" , .value(res$MLE.highrate.value), res$MLE.highrate.rate) +# tbl[2,] <- Vectorize(.italic)(tbl[2,]) +# tbl[3,] <- Vectorize(.italic)(tbl[3,]) +# tbl[7,] <- Vectorize(.italic)(tbl[7,]) +# tbl[8,] <- Vectorize(.italic)(tbl[8,]) + tbl[6,] <- Vectorize(.bold)(tbl[6,]) + tbl[9,] <- Vectorize(.bold)(tbl[9,]) + tbl[1,] <- Vectorize(.bold)(tbl[1,]) + colnames(tbl) <- c(paste0(c(gettext("Description", domain=dm), rep(" ",6)), collapse=""), + gettext("Items", domain=dm), gettext("Value", domain=dm), "%") + x$tbl <- tbl + if (style=="report") { + pander::pandoc.table(x$tbl, digits=2, justify="lrrr", split.tables=Inf, keep.trailing.zeros=TRUE) + } else { + cat("\n-", .f(gettext("Number of Overstatements", domain=dm)), res$sample.over.qty) + cat("\n-", .f(gettext("Number of Understatements", domain=dm)), res$sample.under.qty) + cat("\n-", .f(gettext("Sample Misstatement Amount", domain=dm)), res$sample.miss.value, "(", res$sample.miss.rate , ")") + cat("\n-", .f(gettext("High Values Misstatement Amount", domain=dm)), res$high.miss.value, "(", res$high.miss.rate, ")") + cat("\n-", .f(gettext("Audited Misstatement Amount", domain=dm)), res$audited.miss.value, "(", res$audited.miss.rate, ")") +# cat("\n-", .f(gettext("Most Likely Error", domain=dm)), .write.UEL(x, res$most.likely.error.value)) + cat("\n-", .f(gettext("Most Likely Error", domain=dm)), .write.UEL(x, res$most.likely.error.value)) + if (res$tainting.order != "decreasing") { + cat("\n-", gettext("Tainting Order", domain=dm), res$tainting.order) + } + if (error.rate=="low" || error.rate=="both" || res$sample.miss.qty<20) { + cat("\n-", .f(gettext("Upper Error Limit (Low Error Rate)", domain=dm)), .write.UEL(x, x$UEL.low.error.rate), + .is.acceptable(x$acceptable.low.error.rate)) + if (res$sample.over.qty>0 && res$sample.under.qty>0) { + cat("\n-", .f(gettext("Upper Error Limit (Overstatements)", domain=dm)), .write.UEL(x, round(res$sample.over.uel))) + cat("\n-", .f(gettext("Upper Error Limit (Understatements)", domain=dm)), .write.UEL(x, round(res$sample.under.uel))) + } + cat("\n-", .f(gettext("UEL Acceptable (Low Error Rate)", domain=dm)), .msg.acceptable(x$acceptable.low.error.rate)) + } + if (error.rate=="high" || error.rate=="both" || max(x$Results.Sample$Number.of.Errors)>=20) { + cat("\n-", .f(gettext("Upper Error Limit (High Error Rate)", domain=dm)), .write.UEL(x, x$high.error.rate$upper.error.limit), .is.acceptable(x$acceptable.high.error.rate)) + cat("\n-", .f(gettext("UEL Acceptable (High Error Rate)", domain=dm)), .msg.acceptable(x$acceptable.high.error.rate)) + } + if ("moment.bound" %in% names(x)) { + cat("\n-", .f(gettext("Upper Error Limit (Moment Bound)", domain=dm)), .write.UEL(x, x$moment.bound), .is.acceptable(x$acceptable.moment.bound)) + } + if ("binomial.bound" %in% names(x)) { + cat("\n-", .f(gettext("Upper Error Limit (Binomial Bound)", domain=dm)), .write.UEL(x, x$binomial.bound), .is.acceptable(x$acceptable.binomial.bound)) + } + if ("multinomial.bound" %in% names(x)) { + cat("\n-", .f(gettext("Upper Error Limit (Multinomial Bound)", domain=dm)), .write.UEL(x, x$multinomial.bound), .is.acceptable(x$acceptable.multinomial.bound)) + } + + } + + } + if (print.misstatements && sum(x$Results.Total$Number.of.Errors) > 0) { + cat(paste0("\n\n", gettext("Factual Misstatements", domain=dm), "\n")) if (is.data.frame(x$filled.sample) | is.matrix(x$filled.sample)) { factual <- subset(x$filled.sample, with(x, filled.sample[,col.name.audit.values]!=filled.sample[,col.name.book.values])) if(nrow(factual)>0) { @@ -54,8 +169,102 @@ print.MUS.evaluation.result <- function(x, ...){ } } + + if (print.advice) { + advised <- FALSE + dm <- "R-MUS" + if(!x$acceptable) { + advised <- .write.advice.title(advised, use.pander=use.pander) + if (x$combined) { + if (x$qty.accepted > 0) { + cat("\n*", gettext("Some strata are acceptable.", domain=dm)) + } else { + cat("\n*", gettext("No strata are acceptable.", domain=dm)) + } + cat("\n*", gettext("You have to get further audit evidence or extend the sample.", domain=dm)) + cat("\n*", gettext("You have to book the MLE if it is material.", domain=dm)) + } else { + cat("\n*", gettext("Stratum results are not acceptable.", domain=dm)) + cat("\n*", gettext("You have to get further audit evidence or extend the sample.", domain=dm)) + cat("\n*", gettext("You have to book the MLE if it is material.", domain=dm)) + } + } else { + if (x$combined) { + cat("\n*", gettext("All strata results are acceptable.", domain=dm)) + } else { + cat("\n*", gettext("Stratum results are acceptable.", domain=dm)) + } + cat("\n*", gettext("Audit evidence is sufficient.", domain=dm)) + } + if ((error.rate=="high" || error.rate=="both") && max(x$Results.Sample$Number.of.Errors) < 20) { + advised <- .write.advice.title(advised, use.pander=use.pander) + cat("\n*", gettext("You had less than 20 errors in the sample. Low Error Rate evaluation recommended.", domain=dm)) + } + if ((error.rate=="low" || error.rate=="both") && max(x$Results.Sample$Number.of.Errors)>=20) { + advised <- .write.advice.title(advised, use.pander=use.pander) + cat("\n*", gettext("You had at least 20 errors in the sample. High Error Rate evaluation recommended.", domain=dm)) + } + if (x$Results.Total$Number.of.Errors["understatements"]>0) { + advised <- .write.advice.title(advised, use.pander=use.pander) + cat("\n*", gettext("Please be aware that MUS is not designed to detect understatements, thus they can only be used as an indicator.", domain=dm)) + } + } + cat("\n") # Check book values for NAs, zeros or negative values and repeat warning from MUS.planning if (any(is.infinite(with(x$data, get(x$col.name.book.values))))) warning("There are missing or infinite values (NA, NaN or Inf) as book values in your data. Those elements have no chance for selection. You have to audit them separately.") if (any(with(x$data, get(x$col.name.book.values))==0)) warning("There are zeros as book values in your data. Those elements have no chance for selection. You have to audit them separately.") if (any(with(x$data, get(x$col.name.book.values))<0)) warning("There are negative values as book values in your data. Those elements have no chance for selection. You have to audit them separately.") } + +.write.advice.title <- function(already.printed=FALSE, use.pander=use.pander) { + dm <- "R-MUS" + if (!already.printed) { + cat("\n") + .title(gettext("Recommendations", domain=dm), use.pander=use.pander) + already.printed <- TRUE + } + already.printed +} + +.is.acceptable <- function(x) { + ifelse(x, "*", "") +} +.msg.acceptable <- function(x) { + ifelse(x, gettext("Yes"), gettext("No")) +} + +.write.UEL <- function(x, y, digits=2, format="f", ...) { + #high.miss.value = x$Results.High.values$Net.Value.of.Errors + #population.value <- x$book.value - ifelse(is.data.frame(x$filled.high.values), sum(x$filled.high.values[,x$col.name.book.values]), 0) + population.value <- x$book.value + ifelse(x$error.as.pct, paste0(formatC(100 * y / population.value, format=format, digits=digits, ...), "%"), y) +} + +.percent <- function(x, digits = 2, format = "f", ...) { + # paste0(formatC(100 * x, format = format, digits = digits, ...), "%") + ifelse(is.numeric(x), formatC(100 * x, format = format, digits = digits, ...), "-") +} +.value <- function(x, digits=2, big.mark=NULL, decimal.mark=getOption("OutDec"), ...) { + # paste0(formatC(100 * x, format = format, digits = digits, ...), "%") + big.mark = ifelse(is.null(big.mark), ifelse(decimal.mark==".", ",", "."), big.mark) + ifelse(is.numeric(x), format(round(x, digits), nsmall=digits, big.mark=big.mark, decimal.mark=decimal.mark, ...), "-") +} +.title <- function(x, use.pander=FALSE, level=2) { + if (use.pander && requireNamespace("pander", quietly = TRUE)) { + pander::pandoc.header(x, level=level) + } else { + cat(paste0("\n", x, "\n")) + } +} + +.italic <- function(x) { + paste0("_",x,"_") +} + +.bold <- function(x) { + paste0("__",x,"__") +} + +.f <- function(x) { + sprintf("%-40s", x) +} \ No newline at end of file diff --git a/R/print.MUS.extraction.result.R b/R/print.MUS.extraction.result.R new file mode 100644 index 0000000..5ac0ce2 --- /dev/null +++ b/R/print.MUS.extraction.result.R @@ -0,0 +1,46 @@ +print.MUS.extraction.result <- function(x, print.title=TRUE, print.planning=FALSE, style="default", use.pander=FALSE, ...){ + # Checking parameter + if (class(x)!="MUS.extraction.result" && class(x)!="MUS.evaluation.result" && class(x)!="MUS.planning.result") { + stop("x has to be an object from type MUS.extraction.result or MUS.evaluation.result or MUS.planning.result.") + } + dm <- "R-MUS" + bindtextdomain(dm) + .title(gettext("Extraction Parameters", domain=dm), use.pander=use.pander) + if (print.planning) { + print.MUS.planning.result(x, use.pander=use.pander) + } + + tbl <- matrix(nrow=4, ncol=4) + tbl[1,] = c(gettext("Sample", domain=dm), nrow(x$sample), .value(sum(x$sample[,x$col.name.book.values])), + .percent(sum(x$sample[,x$col.name.book.values]) / x$book.value) ) + tbl[2,] = c(gettext("High Values", domain=dm), nrow(x$high.values), .value(sum(x$high.values[,x$col.name.book.values])), + .percent(sum(x$high.values[,x$col.name.book.values]) / x$book.value) ) + tbl[3,] = c(gettext("Audited", domain=dm), nrow(x$high.values) + nrow(x$sample), + .value(sum(x$high.values[,x$col.name.book.values]) + sum(x$sample[,x$col.name.book.values])), + .percent((sum(x$high.values[,x$col.name.book.values]) + sum(x$sample[,x$col.name.book.values])) / x$book.value) ) + tbl[4,] = c(gettext("Population", domain=dm), nrow(x$data), .value(sum(x$data[,x$col.name.book.values])), + .percent(sum(x$data[,x$col.name.book.values]) / x$book.value) ) + + colnames(tbl) <- c(paste0(c(gettext("Description", domain=dm), rep(" ",6)), collapse=""), + gettext("Items", domain=dm), gettext("Value", domain=dm), "%") + + x$tbl <- tbl + + if (style=="report") { + pander::pandoc.table(x$tbl, digits=2, justify="lrrr", split.tables=Inf, keep.trailing.zeros=TRUE) + } else { + cat("\n-", .f(gettext("Sample items", domain=dm)), nrow(x$sample)) + cat("\n-", .f(gettext("Sample amount", domain=dm)), round(sum(x$sample[,x$col.name.book.values]))) + cat("\n-", .f(gettext("Sample coverage", domain=dm)), .percent(sum(x$sample[,x$col.name.book.values]) / x$book.value)) + + cat("\n-", .f(gettext("High Value items", domain=dm)), nrow(x$high.values)) + cat("\n-", .f(gettext("High Value amount", domain=dm)), round(sum(x$high.values[,x$col.name.book.values]))) + cat("\n-", .f(gettext("High Value coverage", domain=dm)), .percent(sum(x$high.values[,x$col.name.book.values]) / x$book.value)) + + cat("\n-", .f(gettext("Audited items", domain=dm)), round(nrow(x$high.values) + nrow(x$sample))) + cat("\n-", .f(gettext("Audited amount", domain=dm)), round(sum(x$high.values[,x$col.name.book.values]) + + sum(x$sample[,x$col.name.book.values]))) + cat("\n-", .f(gettext("Audited coverage", domain=dm)), .percent((sum(x$high.values[,x$col.name.book.values]) + + sum(x$sample[,x$col.name.book.values])) / x$book.value), "\n") + } +} diff --git a/R/print.MUS.planning.result.R b/R/print.MUS.planning.result.R new file mode 100644 index 0000000..30a68ee --- /dev/null +++ b/R/print.MUS.planning.result.R @@ -0,0 +1,33 @@ +print.MUS.planning.result <- function(x, print.title=TRUE, style="default", use.pander=FALSE, ...){ + # Checking parameter + if (class(x)!="MUS.extraction.result" && class(x)!="MUS.evaluation.result" && class(x)!="MUS.planning.result") { + stop("x has to be an object from type MUS.extraction.result or MUS.evaluation.result or MUS.planning.result.") + } + dm <- "R-MUS" + bindtextdomain(dm) + if (print.title) { + .title(gettext("Planning Parameters", domain=dm), use.pander=use.pander) + } + tbl <- matrix(nrow=4, ncol=4) + tbl[1,] = c(gettext("Expected Error", domain=dm), "-", .value(x$expected.error), .percent(x$expected.error / x$book.value)) + tbl[2,] = c(gettext("Tolerable Error (Materiality)", domain=dm), "-", .value(x$tolerable.error), .percent(x$tolerable.error / x$book.value)) + tbl[3,] = c(gettext("Confidence Level", domain=dm), "-", x$confidence.level, .percent(x$confidence.level)) + tbl[4,] = c(gettext("High Value Threshold", domain=dm), "-", .value(x$High.value.threshold), + ifelse(is.numeric(x$High.value.threshold), .percent(x$High.value.threshold / x$book.value), "-")) + colnames(tbl) <- c(paste0(c(gettext("Description", domain=dm), rep(" ",6)), collapse=""), + gettext("Items", domain=dm), gettext("Value", domain=dm), "%") + x$tbl <- tbl + if (style=="report") { + pander::pandoc.table(x$tbl, digits=2, justify="lrrr", split.tables=Inf, keep.trailing.zeros=TRUE) + } else { + cat("\n-", .f(gettext("Confidence Level", domain=dm)), x$confidence.level) + cat("\n-", .f(gettext("Population size", domain=dm)), nrow(x$data)) + cat("\n-", .f(gettext("Population amount", domain=dm)), x$book.value) + cat("\n-", .f(gettext("Expected Error in population", domain=dm)), x$expected.error) + cat("\n-", .f(gettext("Expected Error Rate", domain=dm)), .percent(x$expected.error / x$book.value)) + cat("\n-", .f(gettext("Tolerable Error (Materiality)", domain=dm)), x$tolerable.error) + cat("\n-", .f(gettext("Tolerable Error Rate", domain=dm)), .percent(x$tolerable.error / x$book.value)) + cat("\n-", .f(gettext("Sample size", domain=dm)), x$n) + cat("\n-", .f(gettext("High Value Threshold", domain=dm)), x$High.value.threshold, "\n") + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..5eeb1c8 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# MUS +MUS - Monetary Unit Sampling and Estimation Methods, Widely Used in Auditing. + +This repository holds (unstable) development versions of the MUS package (R-Project). + +Stable versions are available on CRAN ( https://CRAN.R-project.org/package=MUS ). + +### Prerequisites + +R - https://www.r-project.org/ + +## Contributing + +Contributions are most welcome. + +## Authors + +* **Henning Prömpers** - *Initial work* +* **Andre Guimaraes** + +See also the list of [contributors](https://github.com/alsguimaraes/MUS/contributors) who participated in this project. + diff --git a/build/partial.rdb b/build/partial.rdb index 3b571e8..b37cfa6 100644 Binary files a/build/partial.rdb and b/build/partial.rdb differ diff --git a/examples/data.csv b/examples/data.csv new file mode 100644 index 0000000..cbfd7be --- /dev/null +++ b/examples/data.csv @@ -0,0 +1,1977 @@ +"row","stratum","id","book.value","audit.value" +"1",3,0,531678,531678 +"2",2,1,480499,480499 +"3",3,2,183370,183370 +"4",3,3,547531,547531 +"5",1,4,558986,0 +"6",2,5,495452,0 +"7",3,6,169773,169773 +"8",2,7,240451,240451 +"9",2,8,598190,0 +"10",3,9,409639,409639 +"11",2,10,122785,122785 +"12",3,11,375127,375127 +"13",2,12,630187,630187 +"14",1,13,398662,398662 +"15",3,14,224370,224370 +"16",1,15,230125,230125 +"17",1,16,543580,543580 +"18",1,17,450735,450735 +"19",3,18,499797,499797 +"20",3,19,185809,185809 +"21",3,20,415470,415470 +"22",2,21,308377,308377 +"23",3,22,414409,414409 +"24",2,23,306272,306272 +"25",3,24,569594,569594 +"26",2,25,434229,434229 +"27",2,26,486868,486868 +"28",1,27,312349,0 +"29",1,28,297919,0 +"30",3,29,528771,528771 +"31",3,30,127803,127803 +"32",3,31,379674,379674 +"33",3,32,265901,0 +"34",1,33,203025,203025 +"35",2,34,487876,487876 +"36",3,35,628884,628884 +"37",1,36,526891,526891 +"38",1,37,637474,0 +"39",1,38,377383,377383 +"40",1,39,135154,135154 +"41",2,40,275436,275436 +"42",2,41,499458,0 +"43",2,42,274633,274633 +"44",1,43,15050,15050 +"45",1,44,372895,0 +"46",1,45,113144,0 +"47",2,46,554725,0 +"48",1,47,455093,455093 +"49",3,48,29205,29205 +"50",1,49,220598,220598 +"51",2,50,539800,539800 +"52",3,51,276701,276701 +"53",1,52,267396,267396 +"54",2,53,108586,108586 +"55",1,54,364500,364500 +"56",1,55,334726,0 +"57",3,56,25514,25514 +"58",3,57,638679,638679 +"59",2,58,20102,20102 +"60",2,59,650125,650125 +"61",1,60,27865,27865 +"62",2,61,497633,497633 +"63",1,62,25808,0 +"64",3,63,202836,202836 +"65",2,64,53891,53891 +"66",3,65,522968,0 +"67",3,66,13932,13932 +"68",3,67,140395,140395 +"69",2,68,572423,0 +"70",3,69,342176,342176 +"71",2,70,497141,497141 +"72",3,71,632846,0 +"73",1,72,421884,421884 +"74",2,73,154691,0 +"75",1,74,453472,453472 +"76",2,75,49324,49324 +"77",2,76,359841,359841 +"78",2,77,100497,100497 +"79",1,78,520555,520555 +"80",1,79,59320,59320 +"81",3,80,431703,431703 +"82",2,81,454036,454036 +"83",3,82,257497,257497 +"84",1,83,104214,104214 +"85",2,84,372232,372232 +"86",3,85,381601,0 +"87",3,86,63795,63795 +"88",3,87,556697,556697 +"89",1,88,480232,480232 +"90",1,89,368485,368485 +"91",2,90,307035,307035 +"92",2,91,416025,416025 +"93",2,92,349517,349517 +"94",1,93,202225,202225 +"95",1,94,481559,0 +"96",3,95,626783,626783 +"97",1,96,42220,42220 +"98",2,97,536642,536642 +"99",2,98,403223,403223 +"100",2,99,463994,463994 +"101",1,100,311009,311009 +"102",2,101,338106,338106 +"103",3,102,592004,592004 +"104",2,103,543826,543826 +"105",3,104,146045,146045 +"106",3,105,223817,223817 +"107",2,106,647570,0 +"108",2,107,560943,560943 +"109",1,108,342100,342100 +"110",3,109,174190,174190 +"111",1,110,305316,0 +"112",1,111,218052,0 +"113",3,112,25778,25778 +"114",3,113,63184,63184 +"115",1,114,22870,22870 +"116",2,115,491575,0 +"117",3,116,83970,83970 +"118",2,117,220931,220931 +"119",2,118,405693,0 +"120",2,119,419919,419919 +"121",1,120,120759,120759 +"122",1,121,368128,0 +"123",1,122,59176,59176 +"124",2,123,555121,555121 +"125",3,124,101941,101941 +"126",1,125,391146,0 +"127",1,126,205295,0 +"128",1,127,15900,15900 +"129",3,128,126090,126090 +"130",2,129,8882,8882 +"131",3,130,621995,621995 +"132",3,131,276828,276828 +"133",3,132,393388,393388 +"134",2,133,397741,397741 +"135",2,134,346406,346406 +"136",3,135,355450,355450 +"137",3,136,57459,57459 +"138",3,137,223027,223027 +"139",2,138,588419,0 +"140",1,139,83387,83387 +"141",2,140,312057,312057 +"142",1,141,444032,0 +"143",1,142,605,605 +"144",3,143,123191,123191 +"145",1,144,176158,176158 +"146",1,145,429011,429011 +"147",1,146,605970,605970 +"148",1,147,124048,124048 +"149",3,148,177861,177861 +"150",3,149,152674,152674 +"151",2,150,324813,324813 +"152",2,151,311001,311001 +"153",1,152,137984,137984 +"154",1,153,356239,356239 +"155",2,154,126755,126755 +"156",2,155,311163,0 +"157",1,156,448686,448686 +"158",2,157,241969,241969 +"159",1,158,291177,291177 +"160",2,159,268459,268459 +"161",2,160,424712,424712 +"162",2,161,41574,41574 +"163",2,162,579358,579358 +"164",2,163,171016,171016 +"165",2,164,178534,178534 +"166",3,165,249965,249965 +"167",1,166,149286,0 +"168",2,167,134301,134301 +"169",1,168,541441,541441 +"170",2,169,61476,61476 +"171",1,170,618871,0 +"172",3,171,110725,0 +"173",3,172,184599,184599 +"174",3,173,468105,468105 +"175",2,174,563307,563307 +"176",2,175,470390,470390 +"177",2,176,155903,155903 +"178",3,177,365067,365067 +"179",2,178,197687,197687 +"180",3,179,184132,184132 +"181",1,180,401042,0 +"182",3,181,164093,164093 +"183",1,182,216050,216050 +"184",2,183,106178,106178 +"185",2,184,223227,223227 +"186",1,185,306305,306305 +"187",2,186,610767,610767 +"188",3,187,541763,541763 +"189",3,188,399845,0 +"190",1,189,40356,40356 +"191",1,190,650565,650565 +"192",3,191,279330,279330 +"193",2,192,574308,574308 +"194",3,193,374052,374052 +"195",2,194,304720,304720 +"196",2,195,604171,604171 +"197",2,196,484377,0 +"198",1,197,134745,0 +"199",2,198,574971,574971 +"200",1,199,527612,0 +"201",3,200,301017,301017 +"202",2,201,230642,230642 +"203",2,202,43142,43142 +"204",2,203,186663,186663 +"205",3,204,608046,608046 +"206",2,205,177811,177811 +"207",1,206,651726,651726 +"208",1,207,503562,503562 +"209",1,208,253386,253386 +"210",2,209,332308,332308 +"211",1,210,87241,87241 +"212",1,211,391102,391102 +"213",3,212,94553,94553 +"214",1,213,447220,447220 +"215",3,214,208274,208274 +"216",2,215,99049,0 +"217",2,216,155004,155004 +"218",3,217,533962,533962 +"219",3,218,326204,326204 +"220",1,219,351173,351173 +"221",3,220,119459,119459 +"222",3,221,177351,177351 +"223",3,222,229787,229787 +"224",1,223,245463,245463 +"225",2,224,229905,229905 +"226",2,225,90306,90306 +"227",2,226,258863,258863 +"228",3,227,127714,127714 +"229",3,228,390862,0 +"230",2,229,209180,209180 +"231",2,230,548250,548250 +"232",2,231,503849,503849 +"233",1,232,297563,0 +"234",1,233,444726,0 +"235",2,234,242993,242993 +"236",1,235,546408,546408 +"237",3,236,355192,355192 +"238",1,237,440802,440802 +"239",3,238,269167,0 +"240",2,239,310010,310010 +"241",2,240,18515,0 +"242",1,241,235143,235143 +"243",2,242,520908,520908 +"244",1,243,462984,462984 +"245",3,244,568353,568353 +"246",2,245,86056,86056 +"247",3,246,496647,496647 +"248",3,247,395327,0 +"249",3,248,294004,294004 +"250",1,249,612085,612085 +"251",1,250,471234,471234 +"252",2,251,516512,0 +"253",1,252,251246,251246 +"254",2,253,520409,520409 +"255",3,254,287766,0 +"256",1,255,259456,259456 +"257",2,256,407266,0 +"258",2,257,3608,3608 +"259",3,258,6019,6019 +"260",3,259,208439,208439 +"261",3,260,216587,216587 +"262",3,261,213260,213260 +"263",3,262,249000,249000 +"264",2,263,316531,316531 +"265",2,264,293731,293731 +"266",2,265,651366,651366 +"267",2,266,518069,518069 +"268",1,267,607376,607376 +"269",2,268,169405,169405 +"270",3,269,587501,587501 +"271",1,270,107985,107985 +"272",1,271,28628,28628 +"273",1,272,348952,0 +"274",3,273,184016,0 +"275",3,274,315871,315871 +"276",3,275,324010,324010 +"277",2,276,231175,231175 +"278",1,277,152099,152099 +"279",2,278,632815,632815 +"280",3,279,504651,504651 +"281",1,280,341671,341671 +"282",2,281,423294,423294 +"283",1,282,235039,235039 +"284",1,283,239189,239189 +"285",2,284,452386,452386 +"286",1,285,384294,384294 +"287",1,286,424873,424873 +"288",1,287,83538,83538 +"289",3,288,173914,173914 +"290",1,289,180385,180385 +"291",1,290,266856,266856 +"292",1,291,467241,467241 +"293",3,292,424693,424693 +"294",3,293,10621,10621 +"295",3,294,304001,0 +"296",3,295,425383,425383 +"297",1,296,200304,200304 +"298",1,297,624253,624253 +"299",3,298,610278,610278 +"300",3,299,142710,142710 +"301",1,300,488972,488972 +"302",3,301,166459,166459 +"303",3,302,74969,74969 +"304",2,303,395833,0 +"305",2,304,47533,47533 +"306",1,305,245834,245834 +"307",1,306,277438,277438 +"308",2,307,545570,545570 +"309",2,308,123879,123879 +"310",2,309,262697,262697 +"311",2,310,274126,274126 +"312",3,311,382411,382411 +"313",1,312,305713,305713 +"314",2,313,23514,23514 +"315",3,314,79345,79345 +"316",3,315,580112,580112 +"317",1,316,592215,0 +"318",2,317,365633,365633 +"319",3,318,555920,555920 +"320",3,319,551714,551714 +"321",1,320,496782,496782 +"322",1,321,508386,508386 +"323",3,322,18323,18323 +"324",1,323,108273,108273 +"325",1,324,241865,241865 +"326",3,325,6317,6317 +"327",1,326,156656,156656 +"328",2,327,104013,104013 +"329",3,328,306168,306168 +"330",2,329,45306,45306 +"331",1,330,519702,519702 +"332",3,331,63953,0 +"333",3,332,264236,264236 +"334",1,333,337235,337235 +"335",2,334,170696,170696 +"336",3,335,439423,439423 +"337",2,336,143189,143189 +"338",2,337,515169,515169 +"339",3,338,202452,202452 +"340",2,339,19876,19876 +"341",1,340,46433,46433 +"342",2,341,133026,133026 +"343",1,342,298495,0 +"344",2,343,225221,225221 +"345",2,344,478425,478425 +"346",3,345,36657,36657 +"347",2,346,22538,22538 +"348",1,347,51788,51788 +"349",2,348,254800,254800 +"350",1,349,312364,312364 +"351",3,350,63462,63462 +"352",2,351,371113,0 +"353",1,352,133899,133899 +"354",2,353,161698,161698 +"355",3,354,441342,441342 +"356",3,355,550612,550612 +"357",2,356,295058,295058 +"358",1,357,638990,638990 +"359",3,358,126495,126495 +"360",1,359,165119,165119 +"361",1,360,644443,644443 +"362",3,361,601535,601535 +"363",1,362,98773,98773 +"364",2,363,399243,399243 +"365",3,364,158933,158933 +"366",1,365,134276,134276 +"367",1,366,460565,0 +"368",2,367,628914,628914 +"369",2,368,249047,249047 +"370",2,369,271480,271480 +"371",2,370,315822,315822 +"372",3,371,387679,387679 +"373",2,372,554806,554806 +"374",2,373,200765,200765 +"375",3,374,107777,107777 +"376",3,375,547893,547893 +"377",1,376,232300,232300 +"378",1,377,263903,263903 +"379",3,378,361978,361978 +"380",2,379,215323,215323 +"381",3,380,448110,448110 +"382",2,381,594645,594645 +"383",3,382,394461,394461 +"384",2,383,42901,42901 +"385",3,384,533842,533842 +"386",1,385,144719,144719 +"387",1,386,304917,304917 +"388",1,387,322336,322336 +"389",1,388,167037,167037 +"390",3,389,524505,524505 +"391",1,390,569162,569162 +"392",3,391,344458,0 +"393",3,392,383523,0 +"394",1,393,647772,647772 +"395",1,394,510152,510152 +"396",1,395,459514,459514 +"397",1,396,350118,350118 +"398",1,397,179864,179864 +"399",3,398,624614,0 +"400",3,399,120216,120216 +"401",1,400,632433,0 +"402",3,401,97849,97849 +"403",2,402,344876,344876 +"404",2,403,291999,291999 +"405",2,404,167859,167859 +"406",3,405,80352,80352 +"407",1,406,283335,283335 +"408",2,407,554398,554398 +"409",3,408,33025,33025 +"410",1,409,455750,455750 +"411",3,410,345080,345080 +"412",1,411,15535,15535 +"413",2,412,496333,0 +"414",1,413,391179,391179 +"415",1,414,372991,372991 +"416",3,415,85459,85459 +"417",1,416,470264,470264 +"418",2,417,348636,348636 +"419",1,418,464142,464142 +"420",2,419,175824,175824 +"421",2,420,581756,581756 +"422",2,421,80970,80970 +"423",1,422,80697,0 +"424",3,423,25996,0 +"425",2,424,494204,494204 +"426",1,425,131690,131690 +"427",2,426,330269,330269 +"428",1,427,281379,281379 +"429",3,428,168614,168614 +"430",3,429,468958,468958 +"431",2,430,301596,301596 +"432",1,431,196802,0 +"433",3,432,205324,205324 +"434",1,433,299795,0 +"435",2,434,518198,518198 +"436",1,435,213755,213755 +"437",2,436,609424,0 +"438",1,437,18464,18464 +"439",1,438,56093,56093 +"440",1,439,257967,0 +"441",2,440,171139,171139 +"442",3,441,107215,107215 +"443",1,442,26844,26844 +"444",3,443,331555,331555 +"445",3,444,81345,81345 +"446",3,445,238600,0 +"447",1,446,259167,0 +"448",2,447,195609,195609 +"449",3,448,467813,467813 +"450",2,449,478176,478176 +"451",2,450,571053,0 +"452",1,451,477376,477376 +"453",1,452,23999,23999 +"454",1,453,142314,142314 +"455",3,454,464861,464861 +"456",3,455,378502,0 +"457",3,456,355314,355314 +"458",1,457,574219,574219 +"459",1,458,326320,326320 +"460",3,459,153155,153155 +"461",2,460,376302,0 +"462",2,461,148129,148129 +"463",1,462,645515,645515 +"464",2,463,9652256,0 +"465",1,464,633014,633014 +"466",1,465,648461,648461 +"467",3,466,391727,391727 +"468",1,467,612537,612537 +"469",3,468,163604,163604 +"470",1,469,487431,487431 +"471",3,470,349886,349886 +"472",2,471,535370,535370 +"473",3,472,311484,311484 +"474",2,473,254733,254733 +"475",2,474,646397,646397 +"476",2,475,454177,454177 +"477",1,476,80122,80122 +"478",1,477,514824,514824 +"479",3,478,501119,0 +"480",1,479,143451,143451 +"481",3,480,309536,309536 +"482",1,481,240053,240053 +"483",3,482,256792,256792 +"484",3,483,52884,52884 +"485",1,484,576375,576375 +"486",1,485,12498,12498 +"487",3,486,479645,479645 +"488",2,487,576326,576326 +"489",3,488,309686,309686 +"490",3,489,397574,397574 +"491",1,490,360789,360789 +"492",2,491,400494,0 +"493",3,492,385942,385942 +"494",1,493,472877,472877 +"495",3,494,117200,117200 +"496",1,495,459893,459893 +"497",1,496,242933,242933 +"498",3,497,528015,528015 +"499",3,498,486646,486646 +"500",2,499,309179,309179 +"501",2,500,313442,313442 +"502",1,501,413012,413012 +"503",1,502,370162,0 +"504",2,503,417759,0 +"505",1,504,187882,187882 +"506",2,505,107233,107233 +"507",2,506,120636,0 +"508",3,507,528104,528104 +"509",2,508,5944,5944 +"510",2,509,469662,469662 +"511",1,510,73429,73429 +"512",3,511,629322,629322 +"513",2,512,13052,13052 +"514",3,513,540292,0 +"515",1,514,136878,136878 +"516",2,515,267454,267454 +"517",3,516,600620,0 +"518",1,517,193957,193957 +"519",3,518,77077,77077 +"520",1,519,275446,0 +"521",2,520,333862,333862 +"522",1,521,165920,165920 +"523",1,522,538128,538128 +"524",2,523,322626,322626 +"525",3,524,132978,132978 +"526",3,525,122320,122320 +"527",1,526,157211,0 +"528",3,527,225363,225363 +"529",1,528,477423,477423 +"530",3,529,382132,382132 +"531",3,530,612414,612414 +"532",2,531,145038,145038 +"533",3,532,510901,510901 +"534",1,533,604338,604338 +"535",3,534,257216,0 +"536",2,535,494077,494077 +"537",3,536,378408,378408 +"538",2,537,511845,0 +"539",1,538,492809,492809 +"540",3,539,408243,408243 +"541",1,540,415309,415309 +"542",3,541,117451,117451 +"543",1,542,391897,391897 +"544",3,543,623281,623281 +"545",3,544,339467,339467 +"546",1,545,491481,491481 +"547",3,546,290311,290311 +"548",3,547,167799,167799 +"549",2,548,365319,365319 +"550",1,549,39049,39049 +"551",1,550,289494,0 +"552",2,551,637031,637031 +"553",3,552,438866,438866 +"554",2,553,79050,79050 +"555",2,554,220941,220941 +"556",2,555,191879,191879 +"557",2,556,133077,133077 +"558",2,557,471440,471440 +"559",1,558,415959,415959 +"560",1,559,26996,26996 +"561",3,560,176823,176823 +"562",3,561,127653,0 +"563",1,562,367757,0 +"564",2,563,103726,103726 +"565",2,564,173774,173774 +"566",2,565,454956,454956 +"567",3,566,98341,98341 +"568",2,567,590585,590585 +"569",3,568,560573,560573 +"570",2,569,53341,53341 +"571",3,570,15532,15532 +"572",2,571,648966,648966 +"573",2,572,54191,54191 +"574",3,573,254115,0 +"575",3,574,576648,576648 +"576",2,575,406991,406991 +"577",1,576,95261,95261 +"578",2,577,580903,580903 +"579",2,578,275261,275261 +"580",3,579,424601,424601 +"581",3,580,353186,353186 +"582",3,581,510492,510492 +"583",2,582,426547,426547 +"584",3,583,448662,448662 +"585",1,584,108413,108413 +"586",1,585,100769,100769 +"587",3,586,276083,276083 +"588",3,587,163861,163861 +"589",2,588,130790,0 +"590",2,589,621603,621603 +"591",1,590,129669,129669 +"592",3,591,137169,137169 +"593",1,592,269751,269751 +"594",1,593,323851,323851 +"595",3,594,494842,494842 +"596",2,595,388917,388917 +"597",2,596,35943,35943 +"598",3,597,611617,611617 +"599",1,598,321658,321658 +"600",1,599,482142,482142 +"601",3,600,587134,587134 +"602",1,601,239259,239259 +"603",1,602,488697,488697 +"604",1,603,66646,66646 +"605",3,604,369584,369584 +"606",1,605,515101,515101 +"607",3,606,427666,427666 +"608",1,607,649019,649019 +"609",2,608,483967,483967 +"610",2,609,343726,343726 +"611",1,610,289439,0 +"612",1,611,523131,0 +"613",3,612,97265,97265 +"614",2,613,491052,491052 +"615",3,614,150744,0 +"616",3,615,394106,394106 +"617",3,616,431980,431980 +"618",3,617,175102,175102 +"619",1,618,166061,166061 +"620",3,619,386640,386640 +"621",3,620,476386,476386 +"622",3,621,336114,336114 +"623",2,622,480666,480666 +"624",1,623,588606,588606 +"625",2,624,525048,525048 +"626",1,625,83659,83659 +"627",3,626,603174,603174 +"628",2,627,492046,492046 +"629",1,628,640914,0 +"630",3,629,372691,0 +"631",3,630,258155,258155 +"632",2,631,161062,161062 +"633",3,632,308089,308089 +"634",1,633,276897,0 +"635",1,634,338829,338829 +"636",3,635,235632,235632 +"637",3,636,331835,331835 +"638",3,637,652233,652233 +"639",2,638,230923,230923 +"640",2,639,80680,80680 +"641",3,640,216732,216732 +"642",3,641,384917,384917 +"643",2,642,242033,0 +"644",1,643,79778,79778 +"645",2,644,566586,566586 +"646",3,645,265771,265771 +"647",1,646,251422,251422 +"648",1,647,545083,545083 +"649",2,648,475662,475662 +"650",3,649,375705,375705 +"651",3,650,93304,93304 +"652",2,651,194772,194772 +"653",2,652,502589,502589 +"654",3,653,438580,438580 +"655",3,654,172239,172239 +"656",3,655,480187,480187 +"657",1,656,238952,238952 +"658",2,657,453336,453336 +"659",2,658,178738,178738 +"660",3,659,533534,533534 +"661",3,660,338831,338831 +"662",1,661,35133,35133 +"663",3,662,353734,0 +"664",1,663,127656,127656 +"665",1,664,511629,511629 +"666",3,665,95893,95893 +"667",1,666,301483,301483 +"668",2,667,235395,235395 +"669",1,668,85130,85130 +"670",1,669,28095,28095 +"671",2,670,516954,0 +"672",1,671,147390,0 +"673",1,672,258488,258488 +"674",2,673,230284,230284 +"675",2,674,375921,375921 +"676",3,675,387514,387514 +"677",1,676,51694,51694 +"678",2,677,488595,488595 +"679",2,678,440943,440943 +"680",3,679,358488,358488 +"681",3,680,421274,421274 +"682",3,681,417119,417119 +"683",3,682,186030,186030 +"684",3,683,248805,248805 +"685",2,684,246161,246161 +"686",2,685,257047,0 +"687",1,686,354285,354285 +"688",2,687,128444,128444 +"689",1,688,300626,300626 +"690",1,689,57543,57543 +"691",2,690,390353,390353 +"692",2,691,342446,342446 +"693",1,692,158229,158229 +"694",1,693,144347,144347 +"695",2,694,559062,559062 +"696",1,695,551950,551950 +"697",1,696,36573,36573 +"698",2,697,482399,482399 +"699",2,698,291105,291105 +"700",3,699,198066,198066 +"701",1,700,332212,332212 +"702",1,701,291545,291545 +"703",3,702,635387,635387 +"704",2,703,162603,162603 +"705",2,704,286219,286219 +"706",2,705,512428,512428 +"707",2,706,589253,589253 +"708",1,707,321523,321523 +"709",2,708,563473,563473 +"710",2,709,207918,207918 +"711",2,710,420131,420131 +"712",2,711,244847,244847 +"713",3,712,186317,186317 +"714",2,713,305214,0 +"715",2,714,246978,246978 +"716",1,715,67756,67756 +"717",1,716,248141,0 +"718",3,717,639009,639009 +"719",1,718,418220,418220 +"720",2,719,191831,191831 +"721",3,720,258656,0 +"722",3,721,203911,203911 +"723",3,722,631618,631618 +"724",2,723,67025,67025 +"725",3,724,486241,486241 +"726",3,725,255785,255785 +"727",2,726,502839,502839 +"728",3,727,621572,621572 +"729",1,728,474225,0 +"730",2,729,129544,0 +"731",3,730,650521,650521 +"732",2,731,38518,38518 +"733",3,732,445524,445524 +"734",1,733,630123,630123 +"735",1,734,406067,406067 +"736",3,735,84281,84281 +"737",3,736,143826,143826 +"738",1,737,156711,156711 +"739",1,738,532848,0 +"740",3,739,244374,0 +"741",1,740,470307,470307 +"742",1,741,353571,353571 +"743",2,742,227921,227921 +"744",1,743,1986,1986 +"745",2,744,432960,432960 +"746",3,745,627342,0 +"747",1,746,236487,236487 +"748",3,747,421261,421261 +"749",3,748,201978,0 +"750",1,749,260176,260176 +"751",1,750,466610,466610 +"752",1,751,87970,87970 +"753",1,752,427893,427893 +"754",2,753,650789,650789 +"755",2,754,353112,353112 +"756",2,755,342615,342615 +"757",3,756,485247,485247 +"758",1,757,604479,604479 +"759",1,758,518235,518235 +"760",2,759,452385,452385 +"761",1,760,276969,276969 +"762",2,761,5398,5398 +"763",2,762,137158,0 +"764",2,763,73496,73496 +"765",1,764,292684,292684 +"766",1,765,90716,90716 +"767",2,766,13352560,13352560 +"768",3,767,504336,504336 +"769",2,768,193043,193043 +"770",3,769,137932,137932 +"771",3,770,330719,0 +"772",3,771,34700,34700 +"773",3,772,523823,523823 +"774",1,773,342536,342536 +"775",1,774,243920,243920 +"776",1,775,375395,0 +"777",2,776,482696,482696 +"778",2,777,269726,269726 +"779",3,778,635349,635349 +"780",1,779,604236,604236 +"781",3,780,175931,175931 +"782",1,781,278586,278586 +"783",2,782,450159,450159 +"784",3,783,620482,620482 +"785",2,784,91459,91459 +"786",1,785,56532,56532 +"787",1,786,160538,160538 +"788",1,787,624021,624021 +"789",3,788,160558,160558 +"790",3,789,638372,638372 +"791",2,790,524773,524773 +"792",1,791,609268,609268 +"793",2,792,458498,0 +"794",3,793,323447,323447 +"795",2,794,272399,272399 +"796",1,795,624625,624625 +"797",1,796,62327,62327 +"798",2,797,262531,262531 +"799",1,798,488923,488923 +"800",2,799,409985,409985 +"801",2,800,224555,224555 +"802",1,801,526272,526272 +"803",1,802,434375,434375 +"804",1,803,623902,0 +"805",3,804,328852,328852 +"806",2,805,595123,595123 +"807",2,806,641785,641785 +"808",3,807,386353,386353 +"809",3,808,33800,33800 +"810",1,809,605582,605582 +"811",3,810,130193,130193 +"812",2,811,126073,126073 +"813",3,812,153219,153219 +"814",3,813,262754,262754 +"815",1,814,345154,345154 +"816",1,815,149555,0 +"817",1,816,489375,489375 +"818",2,817,290118,290118 +"819",2,818,473377,0 +"820",3,819,591645,0 +"821",1,820,624122,624122 +"822",2,821,144939,144939 +"823",3,822,46020,0 +"824",3,823,138918,138918 +"825",1,824,222211,222211 +"826",2,825,620135,620135 +"827",1,826,260188,260188 +"828",2,827,108248,108248 +"829",3,828,111929,111929 +"830",1,829,167738,167738 +"831",3,830,11288,11288 +"832",2,831,5258,5258 +"833",3,832,240752,240752 +"834",2,833,39339,39339 +"835",2,834,591331,591331 +"836",3,835,528841,528841 +"837",2,836,216247,216247 +"838",1,837,237000,237000 +"839",1,838,517535,517535 +"840",3,839,185470,185470 +"841",3,840,646534,646534 +"842",2,841,80616,80616 +"843",1,842,86523,86523 +"844",2,843,219617,219617 +"845",1,844,178366,178366 +"846",3,845,549865,549865 +"847",1,846,396072,396072 +"848",1,847,547020,547020 +"849",1,848,349991,349991 +"850",1,849,339325,339325 +"851",3,850,475146,475146 +"852",3,851,8477,8477 +"853",3,852,572205,572205 +"854",2,853,323028,323028 +"855",2,854,528709,528709 +"856",3,855,591737,0 +"857",1,856,513696,0 +"858",1,857,26945,26945 +"859",3,858,479967,479967 +"860",2,859,141928,141928 +"861",1,860,469897,469897 +"862",2,861,327674,327674 +"863",2,862,598311,598311 +"864",2,863,480743,480743 +"865",1,864,633477,633477 +"866",1,865,511687,511687 +"867",1,866,582182,582182 +"868",2,867,280847,280847 +"869",2,868,472249,472249 +"870",1,869,379858,379858 +"871",1,870,495549,495549 +"872",3,871,434411,0 +"873",2,872,53881,53881 +"874",3,873,414183,414183 +"875",3,874,651248,651248 +"876",1,875,474961,474961 +"877",3,876,237087,237087 +"878",3,877,629245,629245 +"879",2,878,476192,476192 +"880",1,879,527334,527334 +"881",3,880,164657,164657 +"882",3,881,177483,177483 +"883",1,882,519710,519710 +"884",3,883,48321,0 +"885",3,884,229729,229729 +"886",2,885,173748,173748 +"887",1,886,184556,184556 +"888",1,887,462228,462228 +"889",1,888,651200,651200 +"890",2,889,590707,590707 +"891",3,890,151557,151557 +"892",3,891,272478,272478 +"893",2,892,213675,213675 +"894",3,893,227117,227117 +"895",3,894,558618,558618 +"896",1,895,437635,437635 +"897",2,896,55679,55679 +"898",1,897,199823,199823 +"899",3,898,291058,291058 +"900",3,899,586780,586780 +"901",2,900,196131,196131 +"902",3,901,396748,396748 +"903",2,902,94145,0 +"904",3,903,486742,486742 +"905",2,904,348635,348635 +"906",3,905,340401,340401 +"907",3,906,17440,17440 +"908",3,907,50482,0 +"909",1,908,635493,635493 +"910",1,909,389405,389405 +"911",1,910,149200,149200 +"912",3,911,40518,0 +"913",2,912,534051,534051 +"914",1,913,434031,434031 +"915",3,914,622712,622712 +"916",2,915,521027,0 +"917",2,916,272712,272712 +"918",2,917,264831,264831 +"919",1,918,373459,373459 +"920",3,919,521749,521749 +"921",1,920,457089,457089 +"922",2,921,394542,394542 +"923",3,922,614484,0 +"924",3,923,627062,0 +"925",3,924,516568,516568 +"926",2,925,406683,406683 +"927",2,926,261244,261244 +"928",1,927,513935,513935 +"929",3,928,168465,168465 +"930",3,929,123929,123929 +"931",1,930,403899,0 +"932",3,931,154303,154303 +"933",2,932,41576,41576 +"934",3,933,124569,124569 +"935",1,934,330275,330275 +"936",2,935,362243,362243 +"937",3,936,304798,304798 +"938",3,937,494770,0 +"939",1,938,594762,0 +"940",3,939,432374,432374 +"941",2,940,575029,575029 +"942",2,941,591997,591997 +"943",2,942,85781,85781 +"944",1,943,420859,420859 +"945",1,944,218966,218966 +"946",2,945,196006,196006 +"947",2,946,234282,234282 +"948",2,947,96034,0 +"949",1,948,523211,523211 +"950",2,949,50983,50983 +"951",1,950,212871,212871 +"952",3,951,239513,239513 +"953",1,952,411363,411363 +"954",2,953,228935,228935 +"955",3,954,477785,477785 +"956",2,955,397553,0 +"957",1,956,91452,91452 +"958",2,957,591410,591410 +"959",2,958,353428,353428 +"960",2,959,400515,400515 +"961",2,960,595156,595156 +"962",2,961,552480,552480 +"963",1,962,458209,458209 +"964",3,963,457902,0 +"965",2,964,191434,191434 +"966",2,965,449909,449909 +"967",1,966,224429,224429 +"968",3,967,93958,93958 +"969",2,968,598934,598934 +"970",3,969,591270,0 +"971",1,970,60581,60581 +"972",3,971,110581,110581 +"973",1,972,289193,289193 +"974",1,973,352803,352803 +"975",2,974,571709,571709 +"976",3,975,81075,81075 +"977",1,976,292970,292970 +"978",2,977,12578,12578 +"979",2,978,347242,347242 +"980",2,979,240154,0 +"981",3,980,245083,245083 +"982",3,981,190064,190064 +"983",2,982,320701,320701 +"984",3,983,283312,283312 +"985",3,984,258786,258786 +"986",1,985,385343,385343 +"987",1,986,76689,76689 +"988",1,987,636095,636095 +"989",2,988,541088,541088 +"990",1,989,225664,225664 +"991",1,990,525797,525797 +"992",2,991,321724,321724 +"993",2,992,583424,583424 +"994",2,993,128409,128409 +"995",3,994,331407,0 +"996",2,995,269376,269376 +"997",2,996,538221,538221 +"998",3,997,308233,0 +"999",1,998,196957,196957 +"1000",1,999,593310,0 +"1001",2,1000,26138,0 +"1002",1,1001,286357,286357 +"1003",3,1002,43938,0 +"1004",3,1003,530054,530054 +"1005",2,1004,143947,143947 +"1006",3,1005,52742,0 +"1007",1,1006,634439,634439 +"1008",1,1007,319349,319349 +"1009",2,1008,548263,548263 +"1010",2,1009,392275,392275 +"1011",2,1010,604062,604062 +"1012",1,1011,87457,0 +"1013",2,1012,574840,0 +"1014",1,1013,106368,106368 +"1015",3,1014,502129,502129 +"1016",2,1015,503432,503432 +"1017",2,1016,580577,580577 +"1018",2,1017,257849,257849 +"1019",1,1018,247778,0 +"1020",2,1019,165367,165367 +"1021",3,1020,288029,288029 +"1022",2,1021,362671,362671 +"1023",2,1022,206135,206135 +"1024",3,1023,138866,138866 +"1025",1,1024,568067,0 +"1026",2,1025,538603,538603 +"1027",2,1026,183791,183791 +"1028",1,1027,250641,250641 +"1029",2,1028,62004,62004 +"1030",1,1029,139747,139747 +"1031",2,1030,554422,554422 +"1032",2,1031,213890,213890 +"1033",1,1032,582551,582551 +"1034",2,1033,61814,0 +"1035",2,1034,389968,389968 +"1036",1,1035,211037,211037 +"1037",2,1036,260503,260503 +"1038",2,1037,322862,322862 +"1039",2,1038,156880,156880 +"1040",3,1039,450853,450853 +"1041",3,1040,56205,0 +"1042",2,1041,231973,231973 +"1043",2,1042,465408,465408 +"1044",1,1043,251092,251092 +"1045",1,1044,251311,251311 +"1046",2,1045,495421,0 +"1047",1,1046,596745,596745 +"1048",3,1047,550487,550487 +"1049",3,1048,52244,52244 +"1050",3,1049,496050,496050 +"1051",3,1050,606597,606597 +"1052",3,1051,314427,314427 +"1053",2,1052,524777,524777 +"1054",2,1053,377175,377175 +"1055",1,1054,170954,170954 +"1056",2,1055,310965,310965 +"1057",1,1056,345006,0 +"1058",1,1057,627999,627999 +"1059",3,1058,309481,309481 +"1060",3,1059,504568,0 +"1061",1,1060,484526,484526 +"1062",1,1061,436270,0 +"1063",2,1062,468033,468033 +"1064",1,1063,354209,0 +"1065",3,1064,94269,0 +"1066",2,1065,151299,0 +"1067",1,1066,283464,283464 +"1068",3,1067,471197,0 +"1069",2,1068,118491,118491 +"1070",3,1069,41884,41884 +"1071",3,1070,606347,606347 +"1072",3,1071,45432,45432 +"1073",3,1072,33682,33682 +"1074",2,1073,410852,410852 +"1075",2,1074,31863,31863 +"1076",1,1075,549831,549831 +"1077",1,1076,503716,503716 +"1078",2,1077,386821,386821 +"1079",2,1078,649444,649444 +"1080",2,1079,631991,631991 +"1081",1,1080,414522,0 +"1082",1,1081,432053,432053 +"1083",2,1082,435592,435592 +"1084",3,1083,304796,0 +"1085",1,1084,187560,0 +"1086",1,1085,472337,472337 +"1087",1,1086,619174,0 +"1088",3,1087,255571,255571 +"1089",2,1088,557810,557810 +"1090",3,1089,194205,194205 +"1091",1,1090,377268,377268 +"1092",1,1091,338482,338482 +"1093",1,1092,615011,615011 +"1094",3,1093,129524,129524 +"1095",3,1094,180548,180548 +"1096",3,1095,569571,569571 +"1097",2,1096,424138,424138 +"1098",1,1097,644057,644057 +"1099",1,1098,156769,156769 +"1100",3,1099,227779,227779 +"1101",3,1100,194746,194746 +"1102",1,1101,478254,478254 +"1103",3,1102,51834,51834 +"1104",3,1103,218732,218732 +"1105",2,1104,416547,416547 +"1106",2,1105,501362,0 +"1107",3,1106,160698,160698 +"1108",3,1107,295805,295805 +"1109",2,1108,329063,329063 +"1110",1,1109,70464,70464 +"1111",3,1110,502400,502400 +"1112",2,1111,234185,234185 +"1113",2,1112,620443,620443 +"1114",1,1113,323846,323846 +"1115",1,1114,498214,498214 +"1116",2,1115,75893,75893 +"1117",3,1116,650939,650939 +"1118",1,1117,244539,244539 +"1119",2,1118,649213,649213 +"1120",1,1119,340386,340386 +"1121",1,1120,351635,351635 +"1122",3,1121,479707,479707 +"1123",1,1122,565741,0 +"1124",1,1123,146444,146444 +"1125",1,1124,531390,531390 +"1126",3,1125,529898,529898 +"1127",2,1126,526025,526025 +"1128",1,1127,83590,83590 +"1129",2,1128,220467,220467 +"1130",2,1129,232814,232814 +"1131",3,1130,601021,601021 +"1132",3,1131,235967,0 +"1133",2,1132,502403,0 +"1134",3,1133,358525,358525 +"1135",3,1134,457246,0 +"1136",2,1135,380147,380147 +"1137",1,1136,206181,0 +"1138",2,1137,197807,197807 +"1139",1,1138,620388,620388 +"1140",3,1139,423949,423949 +"1141",2,1140,168314,0 +"1142",1,1141,281932,281932 +"1143",3,1142,135100,135100 +"1144",1,1143,499066,499066 +"1145",2,1144,646748,646748 +"1146",2,1145,65466,65466 +"1147",2,1146,567889,567889 +"1148",1,1147,81351,81351 +"1149",1,1148,297825,0 +"1150",3,1149,445590,445590 +"1151",2,1150,574969,574969 +"1152",3,1151,600852,600852 +"1153",3,1152,486338,0 +"1154",2,1153,101560,0 +"1155",2,1154,382983,382983 +"1156",1,1155,410517,410517 +"1157",3,1156,157612,157612 +"1158",2,1157,499191,0 +"1159",1,1158,86344,86344 +"1160",2,1159,135137,135137 +"1161",1,1160,390007,0 +"1162",2,1161,363680,363680 +"1163",1,1162,268310,268310 +"1164",1,1163,494018,494018 +"1165",1,1164,142428,142428 +"1166",3,1165,329896,329896 +"1167",1,1166,124697,124697 +"1168",1,1167,9444,9444 +"1169",3,1168,358799,358799 +"1170",2,1169,484755,484755 +"1171",2,1170,44442,44442 +"1172",2,1171,61394,61394 +"1173",3,1172,375155,375155 +"1174",1,1173,320601,320601 +"1175",2,1174,287757,287757 +"1176",3,1175,388835,388835 +"1177",2,1176,508894,508894 +"1178",1,1177,107112,107112 +"1179",2,1178,270531,270531 +"1180",1,1179,3079,3079 +"1181",1,1180,549467,549467 +"1182",3,1181,37540,37540 +"1183",3,1182,368903,368903 +"1184",3,1183,516377,516377 +"1185",1,1184,10686,10686 +"1186",2,1185,623408,623408 +"1187",3,1186,629124,629124 +"1188",3,1187,559416,559416 +"1189",2,1188,22292,22292 +"1190",1,1189,83713,83713 +"1191",2,1190,237436,237436 +"1192",2,1191,121462,0 +"1193",3,1192,154236,154236 +"1194",1,1193,521109,521109 +"1195",1,1194,363244,363244 +"1196",3,1195,477712,0 +"1197",1,1196,297903,0 +"1198",3,1197,460912,460912 +"1199",2,1198,233853,233853 +"1200",3,1199,294726,294726 +"1201",3,1200,327943,0 +"1202",2,1201,344256,344256 +"1203",3,1202,220735,220735 +"1204",2,1203,577297,577297 +"1205",3,1204,364846,364846 +"1206",1,1205,134783,134783 +"1207",1,1206,527397,527397 +"1208",3,1207,213352,213352 +"1209",2,1208,239286,239286 +"1210",2,1209,554124,554124 +"1211",3,1210,89173,89173 +"1212",1,1211,414928,414928 +"1213",2,1212,240009,240009 +"1214",1,1213,520753,520753 +"1215",3,1214,622326,0 +"1216",2,1215,226447,226447 +"1217",3,1216,91955,91955 +"1218",1,1217,366853,366853 +"1219",3,1218,545688,545688 +"1220",2,1219,542447,0 +"1221",2,1220,467869,467869 +"1222",1,1221,210392,210392 +"1223",3,1222,18767,18767 +"1224",3,1223,37617,37617 +"1225",1,1224,113152,113152 +"1226",2,1225,562595,562595 +"1227",1,1226,218315,218315 +"1228",3,1227,175048,175048 +"1229",2,1228,100040,100040 +"1230",1,1229,222296,0 +"1231",1,1230,535168,535168 +"1232",1,1231,592483,592483 +"1233",2,1232,320706,320706 +"1234",1,1233,200435,200435 +"1235",1,1234,440103,440103 +"1236",1,1235,113182,113182 +"1237",3,1236,449958,449958 +"1238",3,1237,475805,475805 +"1239",1,1238,262236,262236 +"1240",1,1239,34761,0 +"1241",1,1240,613020,613020 +"1242",2,1241,576140,576140 +"1243",2,1242,145917,145917 +"1244",3,1243,350222,350222 +"1245",1,1244,498511,498511 +"1246",2,1245,83566,83566 +"1247",1,1246,503229,503229 +"1248",1,1247,227183,0 +"1249",3,1248,114207,114207 +"1250",3,1249,493755,493755 +"1251",2,1250,524319,0 +"1252",2,1251,618840,618840 +"1253",1,1252,26740,26740 +"1254",1,1253,454282,454282 +"1255",3,1254,10283,10283 +"1256",1,1255,204740,204740 +"1257",1,1256,340117,340117 +"1258",3,1257,348214,348214 +"1259",2,1258,32274,32274 +"1260",1,1259,88052,88052 +"1261",2,1260,611359,611359 +"1262",1,1261,2176,2176 +"1263",1,1262,312746,312746 +"1264",3,1263,145608,0 +"1265",1,1264,410282,410282 +"1266",2,1265,531219,531219 +"1267",3,1266,527367,527367 +"1268",1,1267,612042,612042 +"1269",3,1268,139844,139844 +"1270",1,1269,420709,420709 +"1271",3,1270,192561,192561 +"1272",2,1271,613238,0 +"1273",2,1272,189994,189994 +"1274",3,1273,275811,275811 +"1275",2,1274,515267,515267 +"1276",3,1275,299357,299357 +"1277",2,1276,230882,230882 +"1278",1,1277,649416,649416 +"1279",2,1278,617151,0 +"1280",1,1279,353671,353671 +"1281",3,1280,538278,538278 +"1282",2,1281,242531,0 +"1283",3,1282,618802,0 +"1284",2,1283,294317,294317 +"1285",1,1284,201562,201562 +"1286",3,1285,148571,148571 +"1287",2,1286,56933,56933 +"1288",2,1287,362135,362135 +"1289",2,1288,283101,283101 +"1290",3,1289,173398,173398 +"1291",2,1290,208829,208829 +"1292",1,1291,158123,158123 +"1293",3,1292,648083,0 +"1294",2,1293,304232,304232 +"1295",1,1294,50108,50108 +"1296",3,1295,557822,0 +"1297",3,1296,241940,241940 +"1298",3,1297,22703,22703 +"1299",2,1298,2702,2702 +"1300",1,1299,87532,0 +"1301",2,1300,499862,499862 +"1302",2,1301,318832,318832 +"1303",3,1302,412964,412964 +"1304",3,1303,502062,502062 +"1305",2,1304,576482,576482 +"1306",1,1305,341305,0 +"1307",1,1306,533152,533152 +"1308",3,1307,163623,163623 +"1309",1,1308,7370,7370 +"1310",1,1309,356255,356255 +"1311",2,1310,314762,0 +"1312",3,1311,637084,637084 +"1313",1,1312,339847,339847 +"1314",3,1313,637521,637521 +"1315",1,1314,547402,547402 +"1316",3,1315,32624,32624 +"1317",1,1316,543297,543297 +"1318",2,1317,90890,0 +"1319",1,1318,175085,175085 +"1320",3,1319,336659,336659 +"1321",2,1320,157473,157473 +"1322",3,1321,110336,110336 +"1323",2,1322,72593,0 +"1324",3,1323,425225,425225 +"1325",2,1324,5968,5968 +"1326",2,1325,298523,298523 +"1327",2,1326,542869,0 +"1328",1,1327,521129,521129 +"1329",2,1328,68864,68864 +"1330",2,1329,542127,542127 +"1331",1,1330,170133,170133 +"1332",2,1331,509887,509887 +"1333",2,1332,74786,0 +"1334",2,1333,314729,314729 +"1335",1,1334,543073,543073 +"1336",3,1335,62618,62618 +"1337",3,1336,78387,78387 +"1338",3,1337,550623,0 +"1339",2,1338,226526,226526 +"1340",1,1339,605118,605118 +"1341",2,1340,64232,64232 +"1342",2,1341,523720,523720 +"1343",1,1342,446723,446723 +"1344",2,1343,159848,0 +"1345",3,1344,558949,558949 +"1346",1,1345,640896,640896 +"1347",2,1346,70701,70701 +"1348",2,1347,117812,117812 +"1349",2,1348,267191,267191 +"1350",1,1349,209944,209944 +"1351",1,1350,51185,51185 +"1352",1,1351,568592,568592 +"1353",1,1352,174353,174353 +"1354",1,1353,253671,253671 +"1355",2,1354,161049,161049 +"1356",1,1355,329577,329577 +"1357",3,1356,298235,298235 +"1358",1,1357,61590,61590 +"1359",2,1358,506527,506527 +"1360",2,1359,485885,485885 +"1361",1,1360,274844,274844 +"1362",3,1361,493681,493681 +"1363",2,1362,32059,0 +"1364",1,1363,100395,100395 +"1365",1,1364,274274,274274 +"1366",1,1365,188677,188677 +"1367",2,1366,545311,545311 +"1368",1,1367,151094,151094 +"1369",1,1368,498538,0 +"1370",2,1369,231955,0 +"1371",1,1370,105487,105487 +"1372",2,1371,629218,629218 +"1373",2,1372,147136,147136 +"1374",3,1373,363625,363625 +"1375",3,1374,502389,502389 +"1376",2,1375,450846,450846 +"1377",3,1376,45953,45953 +"1378",1,1377,489682,489682 +"1379",2,1378,625094,0 +"1380",2,1379,190318,190318 +"1381",2,1380,224808,224808 +"1382",3,1381,585638,0 +"1383",1,1382,313736,313736 +"1384",3,1383,368995,368995 +"1385",1,1384,237246,237246 +"1386",1,1385,480842,480842 +"1387",3,1386,49678,49678 +"1388",1,1387,544525,544525 +"1389",1,1388,640331,640331 +"1390",3,1389,40719,40719 +"1391",3,1390,376073,376073 +"1392",2,1391,390738,0 +"1393",2,1392,31174,31174 +"1394",2,1393,277032,277032 +"1395",3,1394,378026,0 +"1396",2,1395,261224,261224 +"1397",2,1396,183393,183393 +"1398",1,1397,111932,111932 +"1399",1,1398,565064,565064 +"1400",1,1399,54137,54137 +"1401",1,1400,21430,21430 +"1402",1,1401,639096,0 +"1403",2,1402,362389,362389 +"1404",1,1403,783,783 +"1405",3,1404,486115,486115 +"1406",2,1405,477441,0 +"1407",3,1406,516233,0 +"1408",1,1407,573077,573077 +"1409",3,1408,219725,219725 +"1410",3,1409,483513,483513 +"1411",3,1410,648892,648892 +"1412",2,1411,330233,330233 +"1413",1,1412,107383,0 +"1414",1,1413,522292,522292 +"1415",3,1414,135089,135089 +"1416",2,1415,605173,605173 +"1417",1,1416,360366,360366 +"1418",3,1417,567437,567437 +"1419",2,1418,644717,644717 +"1420",3,1419,631560,631560 +"1421",2,1420,447152,0 +"1422",2,1421,221986,0 +"1423",3,1422,471262,471262 +"1424",2,1423,516983,516983 +"1425",1,1424,205844,205844 +"1426",2,1425,131255,0 +"1427",3,1426,564417,564417 +"1428",3,1427,31367,31367 +"1429",2,1428,335270,335270 +"1430",3,1429,498510,498510 +"1431",1,1430,618730,618730 +"1432",3,1431,562485,0 +"1433",3,1432,49017,0 +"1434",2,1433,240129,240129 +"1435",2,1434,652247,652247 +"1436",2,1435,34561,0 +"1437",3,1436,323586,0 +"1438",2,1437,310095,310095 +"1439",2,1438,102533,102533 +"1440",1,1439,510083,510083 +"1441",2,1440,492360,492360 +"1442",1,1441,507693,507693 +"1443",2,1442,108790,108790 +"1444",3,1443,553462,0 +"1445",3,1444,163110,163110 +"1446",1,1445,241778,0 +"1447",2,1446,194896,194896 +"1448",2,1447,599442,599442 +"1449",1,1448,518789,518789 +"1450",2,1449,177281,177281 +"1451",3,1450,99661,99661 +"1452",3,1451,343934,343934 +"1453",1,1452,584385,584385 +"1454",2,1453,415276,415276 +"1455",3,1454,260593,0 +"1456",1,1455,247427,247427 +"1457",3,1456,259769,259769 +"1458",3,1457,302247,0 +"1459",1,1458,228581,228581 +"1460",3,1459,302449,302449 +"1461",3,1460,624191,624191 +"1462",3,1461,257221,257221 +"1463",1,1462,518771,0 +"1464",1,1463,204799,0 +"1465",3,1464,551227,551227 +"1466",3,1465,318765,318765 +"1467",1,1466,467348,467348 +"1468",2,1467,22413,22413 +"1469",2,1468,610495,610495 +"1470",3,1469,65239,65239 +"1471",1,1470,402540,402540 +"1472",3,1471,127669,127669 +"1473",2,1472,236326,236326 +"1474",2,1473,374682,374682 +"1475",3,1474,164890,0 +"1476",2,1475,581422,581422 +"1477",3,1476,375546,0 +"1478",3,1477,514138,514138 +"1479",3,1478,160027,160027 +"1480",3,1479,567081,567081 +"1481",1,1480,318735,318735 +"1482",3,1481,434878,434878 +"1483",3,1482,115600,115600 +"1484",3,1483,236690,236690 +"1485",1,1484,412176,412176 +"1486",3,1485,203456,203456 +"1487",2,1486,248404,0 +"1488",2,1487,486494,0 +"1489",3,1488,191413,191413 +"1490",1,1489,113390,113390 +"1491",1,1490,427709,427709 +"1492",3,1491,462577,462577 +"1493",3,1492,462267,462267 +"1494",1,1493,269637,269637 +"1495",3,1494,164217,164217 +"1496",3,1495,118051,118051 +"1497",1,1496,345511,345511 +"1498",2,1497,115062,115062 +"1499",2,1498,89143,89143 +"1500",3,1499,181575,181575 +"1501",3,1500,151757,0 +"1502",2,1501,523901,523901 +"1503",1,1502,507123,507123 +"1504",3,1503,190513,190513 +"1505",2,1504,295748,295748 +"1506",2,1505,448573,448573 +"1507",2,1506,136889,136889 +"1508",2,1507,415212,415212 +"1509",2,1508,123502,123502 +"1510",2,1509,450522,450522 +"1511",3,1510,579253,579253 +"1512",3,1511,343370,343370 +"1513",1,1512,56854,56854 +"1514",2,1513,214640,214640 +"1515",2,1514,591525,0 +"1516",1,1515,329982,329982 +"1517",2,1516,306170,306170 +"1518",2,1517,233131,233131 +"1519",1,1518,82413,82413 +"1520",3,1519,298254,298254 +"1521",1,1520,68722,68722 +"1522",3,1521,441789,441789 +"1523",2,1522,178465,178465 +"1524",3,1523,309627,309627 +"1525",1,1524,591095,591095 +"1526",1,1525,175243,175243 +"1527",2,1526,175979,0 +"1528",2,1527,446163,0 +"1529",1,1528,491800,491800 +"1530",3,1529,167389,167389 +"1531",3,1530,503507,503507 +"1532",3,1531,486407,486407 +"1533",2,1532,190710,190710 +"1534",2,1533,70487,70487 +"1535",1,1534,122367,122367 +"1536",2,1535,632574,632574 +"1537",1,1536,207380,207380 +"1538",3,1537,426065,426065 +"1539",2,1538,583778,0 +"1540",1,1539,186529,186529 +"1541",3,1540,105420,0 +"1542",1,1541,409218,0 +"1543",2,1542,627054,627054 +"1544",3,1543,157058,157058 +"1545",1,1544,532877,532877 +"1546",1,1545,144754,144754 +"1547",2,1546,454688,0 +"1548",2,1547,305263,305263 +"1549",3,1548,289521,289521 +"1550",3,1549,315664,315664 +"1551",1,1550,521066,521066 +"1552",2,1551,174504,174504 +"1553",2,1552,426217,426217 +"1554",2,1553,642303,0 +"1555",1,1554,394714,394714 +"1556",3,1555,436221,436221 +"1557",1,1556,495848,495848 +"1558",2,1557,527287,527287 +"1559",3,1558,545353,545353 +"1560",3,1559,552946,552946 +"1561",1,1560,190001,190001 +"1562",3,1561,586361,586361 +"1563",1,1562,230353,230353 +"1564",2,1563,75536,75536 +"1565",1,1564,489467,489467 +"1566",1,1565,136076,136076 +"1567",3,1566,341152,341152 +"1568",1,1567,220138,220138 +"1569",3,1568,311966,311966 +"1570",1,1569,18671,18671 +"1571",1,1570,107315,0 +"1572",3,1571,116026,116026 +"1573",2,1572,133252,133252 +"1574",1,1573,420192,420192 +"1575",3,1574,447513,447513 +"1576",1,1575,628193,628193 +"1577",2,1576,15325,15325 +"1578",1,1577,104304,0 +"1579",2,1578,368310,368310 +"1580",2,1579,150082,150082 +"1581",1,1580,330641,330641 +"1582",1,1581,16452877,0 +"1583",1,1582,635782,635782 +"1584",3,1583,304239,304239 +"1585",2,1584,499906,499906 +"1586",2,1585,154686,0 +"1587",2,1586,155287,155287 +"1588",2,1587,511788,511788 +"1589",2,1588,290087,290087 +"1590",3,1589,352553,352553 +"1591",3,1590,525151,0 +"1592",2,1591,599733,0 +"1593",2,1592,443411,443411 +"1594",1,1593,592866,0 +"1595",1,1594,561857,561857 +"1596",2,1595,416614,416614 +"1597",1,1596,208599,208599 +"1598",3,1597,42273,42273 +"1599",1,1598,496730,496730 +"1600",2,1599,211820,211820 +"1601",1,1600,233841,233841 +"1602",1,1601,554956,554956 +"1603",3,1602,615338,615338 +"1604",3,1603,617263,617263 +"1605",1,1604,81617,81617 +"1606",3,1605,572732,572732 +"1607",1,1606,97527,97527 +"1608",2,1607,202133,202133 +"1609",2,1608,526824,526824 +"1610",2,1609,565333,565333 +"1611",3,1610,393489,0 +"1612",2,1611,10560,10560 +"1613",3,1612,381974,381974 +"1614",3,1613,154873,154873 +"1615",2,1614,554533,554533 +"1616",2,1615,644895,644895 +"1617",2,1616,478389,478389 +"1618",2,1617,424140,424140 +"1619",1,1618,259234,259234 +"1620",1,1619,39773,0 +"1621",1,1620,549979,549979 +"1622",1,1621,584208,584208 +"1623",3,1622,114150,114150 +"1624",2,1623,449885,449885 +"1625",3,1624,363013,0 +"1626",2,1625,92757,92757 +"1627",1,1626,542932,542932 +"1628",2,1627,493378,493378 +"1629",3,1628,122199,122199 +"1630",3,1629,505783,505783 +"1631",2,1630,369989,369989 +"1632",2,1631,440615,440615 +"1633",2,1632,236098,236098 +"1634",3,1633,628562,0 +"1635",3,1634,509893,509893 +"1636",1,1635,173583,173583 +"1637",1,1636,503324,503324 +"1638",1,1637,101662,101662 +"1639",3,1638,440050,440050 +"1640",1,1639,649666,649666 +"1641",3,1640,324664,324664 +"1642",3,1641,604728,604728 +"1643",3,1642,134493,134493 +"1644",2,1643,394156,394156 +"1645",3,1644,400335,400335 +"1646",3,1645,104775,104775 +"1647",3,1646,232817,0 +"1648",2,1647,33347,33347 +"1649",1,1648,242902,242902 +"1650",1,1649,171400,171400 +"1651",3,1650,618387,618387 +"1652",2,1651,288222,0 +"1653",2,1652,92474,92474 +"1654",1,1653,79074,79074 +"1655",2,1654,347993,347993 +"1656",1,1655,561435,561435 +"1657",3,1656,491958,491958 +"1658",1,1657,320516,320516 +"1659",3,1658,9354,0 +"1660",3,1659,181339,181339 +"1661",1,1660,635995,635995 +"1662",1,1661,164834,164834 +"1663",2,1662,504441,504441 +"1664",3,1663,306794,306794 +"1665",2,1664,573762,0 +"1666",3,1665,409741,409741 +"1667",2,1666,495401,495401 +"1668",2,1667,345031,345031 +"1669",1,1668,356056,356056 +"1670",2,1669,592718,592718 +"1671",2,1670,525875,525875 +"1672",1,1671,260458,260458 +"1673",3,1672,536689,536689 +"1674",1,1673,180827,180827 +"1675",2,1674,344901,344901 +"1676",2,1675,453970,453970 +"1677",2,1676,101061,101061 +"1678",2,1677,406252,406252 +"1679",1,1678,405932,405932 +"1680",1,1679,564202,564202 +"1681",2,1680,60604,60604 +"1682",3,1681,178526,0 +"1683",1,1682,643746,643746 +"1684",1,1683,26392,26392 +"1685",1,1684,628983,628983 +"1686",2,1685,507243,507243 +"1687",2,1686,374802,0 +"1688",3,1687,274115,274115 +"1689",3,1688,613917,613917 +"1690",2,1689,120514,120514 +"1691",1,1690,500372,500372 +"1692",1,1691,173510,173510 +"1693",3,1692,319972,319972 +"1694",3,1693,75947,75947 +"1695",3,1694,126906,0 +"1696",3,1695,610963,610963 +"1697",2,1696,4444,4444 +"1698",2,1697,403876,403876 +"1699",1,1698,537424,537424 +"1700",3,1699,222346,222346 +"1701",1,1700,82491,82491 +"1702",2,1701,297964,0 +"1703",3,1702,486790,0 +"1704",3,1703,15034,15034 +"1705",3,1704,240235,0 +"1706",1,1705,42145,42145 +"1707",2,1706,362479,362479 +"1708",3,1707,500758,500758 +"1709",2,1708,494228,494228 +"1710",1,1709,504841,504841 +"1711",1,1710,15017,15017 +"1712",1,1711,483072,483072 +"1713",3,1712,241081,241081 +"1714",2,1713,182702,182702 +"1715",3,1714,415567,415567 +"1716",2,1715,34310,34310 +"1717",2,1716,517204,517204 +"1718",3,1717,188903,188903 +"1719",1,1718,76186,76186 +"1720",3,1719,129028,129028 +"1721",2,1720,384386,384386 +"1722",2,1721,596574,596574 +"1723",1,1722,74646,74646 +"1724",1,1723,111029,0 +"1725",3,1724,646393,646393 +"1726",1,1725,525601,525601 +"1727",2,1726,329215,329215 +"1728",2,1727,199469,199469 +"1729",1,1728,644449,644449 +"1730",3,1729,217492,217492 +"1731",2,1730,293801,293801 +"1732",1,1731,596956,596956 +"1733",3,1732,402135,402135 +"1734",3,1733,68842,68842 +"1735",2,1734,6654,0 +"1736",1,1735,509591,0 +"1737",3,1736,373414,373414 +"1738",3,1737,249848,249848 +"1739",3,1738,217558,0 +"1740",1,1739,97284,97284 +"1741",3,1740,344777,344777 +"1742",2,1741,75121,75121 +"1743",1,1742,511170,511170 +"1744",1,1743,161106,161106 +"1745",1,1744,24093,0 +"1746",3,1745,17121,0 +"1747",3,1746,265311,0 +"1748",3,1747,19814,19814 +"1749",2,1748,351783,0 +"1750",3,1749,499312,499312 +"1751",3,1750,522960,522960 +"1752",3,1751,2321,0 +"1753",2,1752,203090,203090 +"1754",3,1753,640628,640628 +"1755",2,1754,501019,501019 +"1756",3,1755,241802,241802 +"1757",2,1756,300923,300923 +"1758",2,1757,77883,77883 +"1759",3,1758,85656,85656 +"1760",3,1759,180155,180155 +"1761",1,1760,188368,188368 +"1762",1,1761,47607,47607 +"1763",2,1762,418169,418169 +"1764",2,1763,360849,0 +"1765",3,1764,493335,493335 +"1766",3,1765,239455,239455 +"1767",2,1766,111773,111773 +"1768",3,1767,440301,0 +"1769",3,1768,552025,0 +"1770",3,1769,93686,93686 +"1771",2,1770,421643,421643 +"1772",1,1771,427969,427969 +"1773",2,1772,42501,42501 +"1774",1,1773,164357,164357 +"1775",2,1774,276638,276638 +"1776",1,1775,190428,190428 +"1777",1,1776,330699,330699 +"1778",2,1777,588877,588877 +"1779",2,1778,299385,299385 +"1780",1,1779,502960,502960 +"1781",1,1780,408317,408317 +"1782",3,1781,327939,327939 +"1783",2,1782,223955,223955 +"1784",1,1783,508852,508852 +"1785",1,1784,568546,568546 +"1786",3,1785,381039,381039 +"1787",2,1786,294372,294372 +"1788",3,1787,201240,201240 +"1789",3,1788,629894,629894 +"1790",1,1789,117782,117782 +"1791",1,1790,603466,603466 +"1792",2,1791,402424,402424 +"1793",3,1792,562198,562198 +"1794",2,1793,422538,0 +"1795",1,1794,456585,456585 +"1796",2,1795,168423,168423 +"1797",3,1796,639098,639098 +"1798",2,1797,227646,227646 +"1799",2,1798,85947,85947 +"1800",1,1799,428255,428255 +"1801",3,1800,129751,129751 +"1802",1,1801,46817,46817 +"1803",3,1802,12275,12275 +"1804",2,1803,494156,494156 +"1805",1,1804,368414,368414 +"1806",3,1805,112694,112694 +"1807",2,1806,287263,287263 +"1808",3,1807,140145,140145 +"1809",2,1808,70878,0 +"1810",1,1809,631897,631897 +"1811",2,1810,377088,0 +"1812",3,1811,512313,512313 +"1813",3,1812,92160,92160 +"1814",2,1813,6046,6046 +"1815",2,1814,354029,354029 +"1816",2,1815,266393,266393 +"1817",2,1816,6462,6462 +"1818",2,1817,508861,508861 +"1819",1,1818,115640,115640 +"1820",3,1819,209238,209238 +"1821",2,1820,243907,243907 +"1822",1,1821,342908,342908 +"1823",3,1822,544357,544357 +"1824",2,1823,450757,0 +"1825",3,1824,465799,465799 +"1826",1,1825,331907,0 +"1827",3,1826,574271,574271 +"1828",3,1827,466206,466206 +"1829",3,1828,640214,640214 +"1830",3,1829,550167,550167 +"1831",2,1830,220843,220843 +"1832",3,1831,540210,540210 +"1833",1,1832,519184,519184 +"1834",1,1833,285618,285618 +"1835",1,1834,451926,0 +"1836",2,1835,90378,90378 +"1837",1,1836,446576,446576 +"1838",3,1837,151209,151209 +"1839",3,1838,39525,39525 +"1840",2,1839,66469,0 +"1841",2,1840,175231,175231 +"1842",2,1841,400123,400123 +"1843",3,1842,116379,116379 +"1844",2,1843,32647,0 +"1845",1,1844,539767,539767 +"1846",2,1845,89657,89657 +"1847",1,1846,389353,0 +"1848",3,1847,46421,46421 +"1849",1,1848,635890,635890 +"1850",3,1849,645122,645122 +"1851",3,1850,395524,395524 +"1852",2,1851,169335,169335 +"1853",1,1852,492958,492958 +"1854",2,1853,202560,202560 +"1855",2,1854,42512,42512 +"1856",3,1855,142431,0 +"1857",2,1856,11756,11756 +"1858",3,1857,397577,397577 +"1859",3,1858,282772,282772 +"1860",2,1859,422103,422103 +"1861",3,1860,594231,594231 +"1862",1,1861,274673,274673 +"1863",3,1862,402588,402588 +"1864",2,1863,37614,37614 +"1865",1,1864,69320,69320 +"1866",2,1865,586521,586521 +"1867",3,1866,460146,460146 +"1868",2,1867,346551,346551 +"1869",3,1868,446267,446267 +"1870",1,1869,223749,223749 +"1871",3,1870,131278,131278 +"1872",1,1871,466763,466763 +"1873",2,1872,349274,0 +"1874",1,1873,395183,395183 +"1875",3,1874,147548,147548 +"1876",2,1875,8721,8721 +"1877",1,1876,280676,280676 +"1878",3,1877,508067,0 +"1879",2,1878,196862,0 +"1880",3,1879,572577,572577 +"1881",1,1880,362277,362277 +"1882",2,1881,376545,376545 +"1883",1,1882,647707,647707 +"1884",1,1883,215869,215869 +"1885",3,1884,162261,162261 +"1886",1,1885,187126,187126 +"1887",2,1886,585220,585220 +"1888",1,1887,260690,260690 +"1889",2,1888,249071,249071 +"1890",2,1889,476832,476832 +"1891",3,1890,297755,297755 +"1892",1,1891,607810,607810 +"1893",3,1892,285508,0 +"1894",3,1893,498522,498522 +"1895",2,1894,434576,434576 +"1896",2,1895,56178,56178 +"1897",3,1896,294927,294927 +"1898",1,1897,291060,291060 +"1899",2,1898,30811,30811 +"1900",2,1899,527600,527600 +"1901",1,1900,403096,403096 +"1902",1,1901,304739,304739 +"1903",3,1902,638734,638734 +"1904",2,1903,242660,0 +"1905",2,1904,346225,346225 +"1906",2,1905,229108,229108 +"1907",3,1906,159103,159103 +"1908",2,1907,392887,392887 +"1909",2,1908,236412,236412 +"1910",1,1909,614500,0 +"1911",2,1910,436573,0 +"1912",2,1911,490222,490222 +"1913",2,1912,261390,0 +"1914",2,1913,207079,207079 +"1915",1,1914,45383,0 +"1916",1,1915,49974,49974 +"1917",3,1916,563168,563168 +"1918",3,1917,459563,459563 +"1919",1,1918,292815,292815 +"1920",3,1919,429279,429279 +"1921",2,1920,483548,483548 +"1922",3,1921,69995,69995 +"1923",2,1922,565615,0 +"1924",2,1923,587284,587284 +"1925",2,1924,516200,516200 +"1926",2,1925,454884,454884 +"1927",1,1926,13358,13358 +"1928",2,1927,37144,37144 +"1929",3,1928,132589,0 +"1930",2,1929,377620,377620 +"1931",2,1930,574800,574800 +"1932",1,1931,196226,196226 +"1933",1,1932,114592,114592 +"1934",1,1933,571347,571347 +"1935",1,1934,138481,138481 +"1936",2,1935,441550,441550 +"1937",3,1936,130058,130058 +"1938",1,1937,26920,26920 +"1939",3,1938,428068,428068 +"1940",2,1939,309292,309292 +"1941",1,1940,649653,649653 +"1942",1,1941,523143,0 +"1943",3,1942,599352,599352 +"1944",1,1943,441404,441404 +"1945",3,1944,353881,353881 +"1946",1,1945,32929,32929 +"1947",2,1946,595139,595139 +"1948",3,1947,90441,90441 +"1949",1,1948,614478,614478 +"1950",1,1949,585109,585109 +"1951",3,1950,260268,260268 +"1952",1,1951,216151,216151 +"1953",1,1952,265238,265238 +"1954",2,1953,399194,399194 +"1955",2,1954,648472,648472 +"1956",2,1955,328327,328327 +"1957",3,1956,351225,351225 +"1958",2,1957,272871,0 +"1959",1,1958,629925,0 +"1960",3,1959,463562,463562 +"1961",1,1960,502033,502033 +"1962",1,1961,622384,622384 +"1963",1,1962,296611,0 +"1964",2,1963,190739,190739 +"1965",2,1964,112659,112659 +"1966",1,1965,178450,0 +"1967",1,1966,188506,188506 +"1968",3,1967,32153,32153 +"1969",2,1968,591436,0 +"1970",1,1969,29741,29741 +"1971",3,1970,358287,0 +"1972",2,1971,12858,12858 +"1973",2,1972,313182,313182 +"1974",3,1973,503193,503193 +"1975",2,1974,211311,211311 +"1976",1,1975,338058,338058 diff --git a/examples/example.R b/examples/example.R new file mode 100644 index 0000000..28460b7 --- /dev/null +++ b/examples/example.R @@ -0,0 +1,380 @@ +# Simple Example +library(MUS) +library(pander) +library(ggplot2) +library(rmarkdown) +library(animation) + +calc.n <- function(conf_level, pct_tolerable, pct_expected) { + pct_ratio <- pct_expected / pct_tolerable + conf_factor <- ceiling(MUS.factor(conf_level, pct_ratio)*100)/100 + n <- ceiling(conf_factor / pct_tolerable) + n +} + +calc.all <- function(dados, conf_level=0.95, pct_tolerable=0.1, pct_expected=0.05) { + if(!"conf_level" %in% colnames(dados)) { + dados$conf_level <- conf_level + } + if(!"pct_tolerable" %in% colnames(dados)) { + dados$pct_tolerable <- pct_tolerable + } + if(!"pct_expected" %in% colnames(dados)) { + dados$pct_expected <- pct_expected + } + if(!"stratum" %in% colnames(dados)) { + dados$stratum <- ceiling(runif(n=nrow(dados), min=0, max=3)) + } + dados$sizes=0 + sizes <- by(dados, dados$stratum, function(x) { calc.n(conf_level=x$conf_level, pct_tolerable=x$pct_tolerable, pct_expected=x$pct_expected) }) + dados$sizes <- c(sizes) + dados +} + +format_si <- function(...) { + function(x) { + limits <- c(1e0, 1e3, 1e6, 1e9, 1e12) + prefix <- c(" ", "k", "M", "B", "T") + + # Vector with array indices according to position in intervals + i <- findInterval(abs(x), limits) + + # Set prefix to " " for very small values < 1e-24 + i <- ifelse(i==0, which(limits == 1e0), i) + + paste(format(round(x/limits[i], 1), + trim=TRUE, scientific=FALSE, ...), + prefix[i]) + } +} + +format_pct <- function(...) { + function(x) { + x*100 + } +} + +format_exp <- function(...) { + function(x) { + x <- exp(x) + limits <- c(1e0, 1e3, 1e6, 1e9, 1e12) + prefix <- c(" ", "k", "M", "B", "T") + + # Vector with array indices according to position in intervals + i <- findInterval(abs(x), limits) + + # Set prefix to " " for very small values < 1e-24 + i <- ifelse(i==0, which(limits == 1e0), i) + + paste(format(round(x/limits[i], 1), + trim=TRUE, scientific=FALSE, ...), + prefix[i]) + } +} + +# setup options and variables +ani.options(pdftk = '/bin/pdftk') +if (!file.exists('/bin/pdftk')) { + ani.options(pdftk = '/tools/pdftk/pdftk.exe') +} +panderOptions('keep.trailing.zeros', T) +panderOptions('round', 2) +panderOptions('digits', 19) + +if (!exists("id.amostragem")) { + id.amostragem <- 1 +} +MUS.seed <- id.amostragem %% 1000 + +if (!exists("MUS.step")) { + MUS.step <- 3 +} + +use.pander <- TRUE +conf_level <- 0.95 +if ( !"sdados" %in% ls() ) { + H <- 1 # number of strata + sdados = data.frame("stratum"=1:H, + "conf_level"=rep(conf_level, H), + "pct_tolerable"=rep(0.15, H), + "pct_expected"=rep(0.10, H) + ) +} +sdados <- calc.all(sdados) + +# Assume 5000 invoices, each between 1 and 1000 monetary units +if ( MUS.step==1 & ( !"dados" %in% ls() ) ) { + dados <- data.frame( + book.value=round(runif(n=5000, min=10, max=1000)), + stratum=round(runif(n=5000, min=1, max=nrow(sdados))) + ) +} + +if(!"stratum" %in% colnames(dados)) { + dados$stratum <- 1 +} +if(!"nf" %in% colnames(dados)) { + dados$nf <- ceiling(runif(n=nrow(dados), min=1, max=1000)) +} +if(!"rubrica" %in% colnames(dados)) { + dados$rubrica <- paste("rubrica ", ceiling(runif(n=nrow(dados), min=1, max=10))) +} +uniq.rubrica <- unique(dados$rubrica) +dados$id.rubrica <- as.factor(match(dados$rubrica, uniq.rubrica)) +soma.rubrica <- c(by(dados$book.value, dados$id.rubrica, sum)) +qtd.rubrica <- c(by(dados$book.value, dados$id.rubrica, length)) +rubricas <- data.frame(id=as.numeric(names(soma.rubrica)), nome=uniq.rubrica[as.numeric(names(soma.rubrica))], qty=as.numeric(qtd.rubrica), value=as.numeric(soma.rubrica)) + +rownames(dados) <- c(1:nrow(dados)) +if(!"id" %in% colnames(dados)) { + dados$id <- c(1:nrow(dados)) +} +if(!"audit.value" %in% colnames(dados)) { + dados$audit.value <- dados$book.value*(1-rbinom(nrow(dados), 1, 0.15)) +} +if(!"selected" %in% colnames(dados)) { + dados$selected <- 0 +} + +if (!exists("inclui_total")) { + inclui_total <- FALSE +} +if (!inclui_total && MUS.step!=4) { + plans <- list() + extract <- list() + audited <- list() + audited.high <- list() + evaluation <- list() +} + +strata <- unique(sdados$stratum) +# combina estratos +if ((!inclui_total) & (length(strata)>1) & (MUS.step == 4)) { + plans <- c(list(MUS.combine(plans)), plans) + extract <- c(list(MUS.combine(extract)), extract) + evaluation <- c(list(MUS.combine(evaluation)), evaluation) + inclui_total <- TRUE +} + +if (inclui_total & length(strata)>1) { + strata <- c(1, 1+strata) +} + +dm <- "R-MUS" +bindtextdomain(dm) + +cat("\n\n") +resultados <- rep(NULL, length(strata)) +erro.provavel <- rep(NULL, length(strata)) +for (s in strata) { + numStratum <- s + if (inclui_total & length(strata)>1) { + if (s>1) { + cat("\n\\newpage\n") + } + numStratum <- numStratum - 1 + } + MUS:::.title(ifelse(inclui_total & length(strata)>1 & s==1, + paste0(gettext("Population", domain=dm), " (", length(strata)-1, " ", gettext("strata", domain=dm), ")"), + paste(gettext("Stratum", domain=dm), numStratum)), level=1, use.pander=use.pander) + rs <- (dados$stratum == numStratum) + if (inclui_total & length(strata)>1 & s==1) { + rs <- TRUE + } + + if (sum(rs)==0) { + cat("\nno records...\n") + } else { + + if (MUS.step > 0) { +# cat("\n\tplanning...\n") + if (!inclui_total) { + plans[[s]] <- MUS.planning(data=dados[rs,], + tolerable.error=sum(sdados$pct_tolerable[s] * dados$book.value[rs]), + expected.error=sum(sdados$pct_expected[s] * dados$book.value[rs]), + n.min=mean(sdados$sizes[s]) ) + } + print(plans[[s]], style="report", use.pander=use.pander) + } + + if (MUS.step > 1) { +# cat("\n\textracting...\n") + if (!inclui_total) { + extract[[s]] <- MUS.extraction(plans[[s]], seed=MUS.seed, obey.n.as.min=TRUE) + dados$selected[dados$stratum == s] <- 0 + dados$selected[dados$id %in% extract[[s]]$sample$id] <- 1 + if (is.data.frame(extract[[s]]$high.values)) { + dados$selected[dados$id %in% extract[[s]]$high.values$id] <- 2 + } + } + print(extract[[s]], style="report", use.pander=use.pander) + } + if (MUS.step > 2) { +# cat("\n\tevaluating...\n") + # Copy book values into a new column audit values + # Evaluate the sample, cache and print it + if (!inclui_total) { + audited[[s]] <- extract[[s]]$sample + audited.high[[s]] <- extract[[s]]$high.values + evaluation[[s]] <- MUS.evaluation(extract[[s]], audited[[s]], audited.high[[s]], print.advice=FALSE, tainting.order="decreasing", experimental=FALSE) + } + print(evaluation[[s]], print.misstatements=FALSE, style="report", use.pander=use.pander) + cat("\n") + resultados[s] <- evaluation[[s]]$acceptable + mle <- evaluation[[s]]$MLE.final +# errohighvalues <- evaluation[[s]]$Results.High.values$Net.Value.of.Errors + erroLiquidoAmostra <- evaluation[[s]]$Results.Sample$Gross.Value.of.Errors[1] - evaluation[[s]]$Results.Sample$Gross.Value.of.Errors[2] + erroLiquidoHighValues <- evaluation[[s]]$Results.High.values$Gross.Value.of.Errors[1] - evaluation[[s]]$Results.High.values$Gross.Value.of.Errors[2] + erroTotal <- erroLiquidoAmostra + erroLiquidoHighValues + parcial <- evaluation[[s]]$book.value - sum(audited[[s]]$book.value) - ifelse(is.data.frame(evaluation[[s]]$filled.high.values), sum(evaluation[[s]]$filled.high.values$book.value), 0) + erro.provavel[s] <- (mle - erroTotal) / parcial + } + + if (MUS.step > 3) { + + cat("\n\\newpage\n") + cat("\n## Gráficos\n") + op<-par(mfrow=c(3,2)) + fsample <- evaluation[[s]]$filled.sample + pop <- evaluation[[s]]$data + comb.fsample <- rbind(data.frame(g=rgb(0,0.7,0.1,0.4), v=fsample$book.value), data.frame(g=rgb(0,0.1,0.7,0.4), v=fsample$audit.value)) + + tsoma.rubrica <- c(by(pop$book.value, pop$id.rubrica, sum)) + tqtd.rubrica <- c(by(pop$book.value, pop$id.rubrica, length)) + trubricas <- data.frame(id=as.numeric(names(tsoma.rubrica)), + nome=uniq.rubrica[as.numeric(names(tsoma.rubrica))], + qty=as.numeric(tqtd.rubrica), + value=as.numeric(tsoma.rubrica) + ) + + orubricas <- trubricas + trubricas$pct <- Vectorize(MUS:::.percent)(trubricas$value / sum(trubricas$value)) + trubricas$value <- Vectorize(MUS:::.value)(trubricas$value) + comb.pop <- rbind(data.frame(g=rgb(0,0.7,0.1,0.4), v=pop$book.value), data.frame(g=rgb(0,0.1,0.7,0.4), v=pop$audit.value)) + + colnames(trubricas) <- c("Id", paste0(c(gettext("Description", domain=dm), rep(" ",5)), collapse=""), + gettext("Items", domain=dm), gettext("Value", domain=dm), "%") + + pop.grid <- theme( + panel.background = element_rect(fill = "powderblue", + colour = "powderblue", + size = 0.5, linetype = "solid"), + panel.grid.major = element_line(size = 0.5, linetype = 'solid', + colour = "white"), + panel.grid.minor = element_line(size = 0.25, linetype = 'solid', + colour = "white") + ) + + h1 <- ggplot(fsample, aes(x=book.value)) + + geom_histogram(bins = 6, color="white", fill=rgb(0,0.7,0.1,0.4)) + + scale_x_continuous(labels=format_si()) + + ggtitle("Amostra") + + xlab("valor informado") + ylab("qtd") + print(h1) + h2 <- ggplot(fsample, aes(x=audit.value)) + + geom_histogram(bins = 6, color="white", fill=rgb(0,0.1,0.7,0.4)) + + scale_x_continuous(labels=format_si()) + + ggtitle("Amostra") + + xlab("valor auditado") + ylab("qtd") + print(h2) + + h3 <- ggplot(fsample[fsample$book.value != fsample$audit.value,], aes(x=(book.value - audit.value))) + + geom_histogram(bins = 6, color="white", fill=rgb(0.7,0.1,0.1,0.4)) + + scale_x_continuous(labels=format_si()) + + ggtitle("Amostra") + + xlab("distor\u{E7}\u{F5}es") + ylab("qtd") + print(h3) + h4 <- ggplot(pop, aes(x=book.value)) + + geom_histogram(bins = 6, color="white", fill=rgb(0,0.7,0.1,0.4)) + + pop.grid + +# scale_x_log10(labels=format_si()) + + scale_x_continuous(labels=format_si()) + + ggtitle("Popula\u{E7}\u{E3}o") + + xlab("valor informado") + ylab("qtd") + suppressWarnings(print(h4)) + merge_histograms <- (length(unique(fsample$stratum)) > 1) + if (merge_histograms) { + h5 <- ggplot(fsample, aes(x=as.factor(stratum), y=book.value)) + + geom_boxplot(fill=rgb(0,0.7,0.1,0.4), outlier.color=NA) + + scale_y_continuous(labels=format_si()) + + ggtitle("Amostra") + + xlab("estrato") + ylab("valor informado") + suppressWarnings(print(h5)) + h6 <- ggplot(pop, aes(x=as.factor(stratum), y=book.value)) + + geom_boxplot(fill=rgb(0,0.7,0.1,0.4), outlier.color=NA) + + pop.grid + + scale_y_continuous(labels=format_si()) + + ggtitle("Popula\u{E7}\u{E3}o") + + xlab("estrato") + ylab("valor informado") + suppressWarnings(print(h6)) + } else { + if (nrow(trubricas) <= 20) { + g1 <- ggplot(fsample, aes(x=as.factor(id.rubrica), y=book.value)) + + geom_boxplot(fill=rgb(0,0.7,0.1,0.4), outlier.color=NA) + + scale_y_continuous(labels=format_si()) + + ggtitle("Amostra") + + xlab("rubrica") + ylab("valor informado") + suppressWarnings(print(g1)) + g2 <- ggplot(pop, aes(x=as.factor(id.rubrica), y=book.value)) + + geom_boxplot(fill=rgb(0,0.7,0.1,0.4), outlier.color=NA) + + pop.grid + + scale_y_continuous(labels=format_si()) + + ggtitle("Popula\u{E7}\u{E3}o") + + xlab("rubrica") + ylab("valor informado") + suppressWarnings(print(g2)) + } else { + g1 <- ggplot(orubricas[order(-orubricas$value),], aes(x=1:nrow(orubricas), y=cumsum(value)/evaluation[[s]]$book.value)) + + geom_point(color=rgb(0,0.7,0.1,1), size=2.5) + + scale_y_continuous(labels=format_pct()) + + ggtitle("Amostra") + + xlab("rubricas") + ylab("valor informado acum.") + print(g1) + g2 <- ggplot(rubricas[order(-rubricas$value),], aes(x=1:nrow(rubricas), y=cumsum(value)/evaluation[[s]]$book.value)) + + geom_point(color=rgb(0,0.7,0.1,1), size=2.5) + + pop.grid + + scale_y_continuous(labels=format_pct()) + + ggtitle("Popula\u{E7}\u{E3}o") + + xlab("rubricas") + ylab("valor informado acum.") + print(g2) + } + } + + par(op) + cat("\n") + + if (nrow(trubricas)>9) { + cat("\n\\newpage\n") + } + MUS:::.title("Rubricas", use.pander=TRUE, level=2) + pandoc.table(trubricas, justify="clrrr") + if (inclui_total & s==1) { + MUS:::.title("Anexos", use.pander=TRUE, level=2) + cat("\n- dados.csv")/ + cat("\n- script.R") + cat("\n- diagnostico.txt\n\n") + } + } + + } +} + +selected <- dados$id[dados$selected==1] +highvalues <- dados$id[dados$selected==2] +#resultados + +if ((MUS.step > 4) & file.exists('work.pdf')) { + sink("diagnostico.txt") + cat("Informações da Sessão\n\n") + print(sessionInfo()) + cat("\n\nVersão do R\n\n") + print(version) + sink() + write.csv(dados, file="dados.csv") + pdftk("work.pdf", "attach_files dados.csv example.R diagnostico.txt", "report.pdf" ) + unlink(c("work.pdf", "dados.csv", "diagnostico.txt", "example.Rmd", "example.R", "logo.png")) +} + +#moment.bound(c(rep(0, 96), -.16, .04, .18, .47)) +#moment.bound(c(rep(0, 95), -75, -25, 25, 40, 60, 75)/100) +#moment.bound(c(rep(0, 96), 75, -60, -40, -25, 99)/100) +#moment.bound(c(rep(0, 93), -50, -50,50,50,50,50,50,50)/100) diff --git a/examples/example.Rmd b/examples/example.Rmd new file mode 100644 index 0000000..6e56a5c --- /dev/null +++ b/examples/example.Rmd @@ -0,0 +1,42 @@ +--- +#title: "MUS" +#author: "Andre Guimaraes" +#date: "25/08/2017" + +header-includes: + - \usepackage{helvet} + - \usepackage[T1]{fontenc} + - \usepackage{fancyhdr} + - \usepackage{lastpage} + - \renewcommand\familydefault{\sfdefault} + +output: + pdf_document: + latex_engine: xelatex + toc: true + toc_depth: 1 + +mainfont: helvetica +fontsize: 12pt + +geometry: + - tmargin=2cm + - bmargin=3cm + - lmargin=2cm + - rmargin=2cm + +documentclass: article +classoption: a4paper +--- +\pagestyle{fancyplain} +\addtolength{\headheight}{\baselineskip} +\lhead{\includegraphics[height=0.8cm]{logo.png}} +\rhead{\fontsize{8}{10}\selectfont \textit{P\'agina}\\\fontsize{10}{12}\selectfont \smallskip\textbf{\thepage} de \textbf{\pageref*{LastPage}}} +\lfoot{\fontsize{8}{10}\selectfont \textit{Grau de Sigilo}\\\smallskip\textbf{Controlado - sigilo empresarial}} +\cfoot{\fontsize{8}{10}\selectfont \textit{Restri\c{c}\~ao de Acesso}\\\smallskip\textbf{Empresas do Sistema BNDES}} +\rfoot{\fontsize{8}{10}\selectfont \textit{Unidade Gestora}\\\smallskip\textbf{ATI}} +\renewcommand{\headrulewidth}{0pt} + +```{r echo=FALSE, warning=FALSE, title=FALSE, comment='', results='asis', fig.show='asis', fig.height=3.2, fig.width=3.4, out.width=".49\\linewidth"} +source("example.R") +``` diff --git a/examples/logo.png b/examples/logo.png new file mode 100644 index 0000000..793706f Binary files /dev/null and b/examples/logo.png differ diff --git a/examples/workflow.R b/examples/workflow.R new file mode 100644 index 0000000..ddc81b6 --- /dev/null +++ b/examples/workflow.R @@ -0,0 +1,55 @@ +# diretorio inicial +#setwd("/home/ALSOU/MUS") +#setwd("/projetos/MUS") + +rm(list=ls()) +origem <- "/home/ALSOU/MUS/examples" +origemWindows <- "/projetos/MUS/examples" +if ((!file.exists(origem)) & file.exists(origemWindows)) { + origem <- origemWindows +} +origem <- paste0(origem, "/") + +file.copy(c(paste0(origem, "example.R")), getwd()) +# carrega os data frames +H <- 3 # qtd de estratos +conf_level <- 0.95 +sdados = data.frame("stratum"=1:H, + "conf_level"=rep(conf_level, H), + "pct_tolerable"=rep(0.1, H), + "pct_expected"=rep(0.05, H)) + +# planeja a amostra +inclui_total <- FALSE +MUS.step <- 1 +print(sdados) +source("example.R") +# n para cada estrato em sdados$sizes +print(sdados) + +# seleciona amostra +MUS.step <- 2 +source("example.R") +# selecionados em selected +print(selected) + +# avalia +MUS.step <- 3 +source("example.R") + +# gera pdf +MUS.step <- 4 +file.copy(c(paste0(origem, "example.Rmd"), paste0(origem, "logo.png")), getwd()) +rmarkdown::render(input="example.Rmd", + output_format="pdf_document", + output_file='work.pdf', + output_options=list() +) +unlink(c("example.Rmd", "logo.png")) + +# inclui attachments no pdf +MUS.step <- 5 +source("example.R") + +# cleanup +unlink(c("report.pdf", "example.R")) diff --git a/inst/po/en@quot/LC_MESSAGES/R-MUS.mo b/inst/po/en@quot/LC_MESSAGES/R-MUS.mo new file mode 100644 index 0000000..ffaf2fc Binary files /dev/null and b/inst/po/en@quot/LC_MESSAGES/R-MUS.mo differ diff --git a/inst/po/pt_BR/LC_MESSAGES/R-MUS.mo b/inst/po/pt_BR/LC_MESSAGES/R-MUS.mo new file mode 100644 index 0000000..0f87c78 Binary files /dev/null and b/inst/po/pt_BR/LC_MESSAGES/R-MUS.mo differ diff --git a/man/MUS.binomial.bound.Rd b/man/MUS.binomial.bound.Rd new file mode 100644 index 0000000..b67ce64 --- /dev/null +++ b/man/MUS.binomial.bound.Rd @@ -0,0 +1,44 @@ +\encoding{UTF-8} +\name{MUS.binomial.bound} +\alias{MUS.binomial.bound} +\title{Calculate a binomial bound for a Monetary Unit Sampling evaluation.} +\description{ + Calculates a binomial bound for a Monetary Unit Sampling evaluation. + + Please treat as experimental. +} +\usage{ + MUS.binomial.bound(x, scope, as.pct, include.high.values, confidence.level) +} +\arguments{ + \item{x}{A MUS.evaluation.result object (or a tainting vector) used to calculate the binomial bound.} + \item{scope}{The required scope for the bound ("qty" or "value"). Default is "value".} + \item{as.pct}{Boolean. Express results as percentage. Default is False.} + \item{include.high.values}{Boolean. Whether the bound should include high values. Default is "TRUE".} + \item{confidence.level}{The required confidence level. Default is 95\%.} +} +\value{ + Upper Error Limit calculed using the binomial bound. +} +\author{Andre Guimaraes } +\seealso{ + \code{\link{MUS.evaluation}} for evaluation of the audited sample. +} +\examples{ + +# Assume 500 invoices, each between 1 and 1000 monetary units +data <- data.frame(book.value=round(runif(n=500, min=1, max=1000))) +# Plan a sample and cache it +plan <- MUS.planning(data=data, tolerable.error=10000, expected.error=2000) +# Extract a sample and cache it (no high values exist in this example) +extract <- MUS.extraction(plan) +# Copy book value into a new column audit values, and inject some error +audited <- extract$sample$book.value*(1-rbinom(nrow(extract$sample), 1, 0.05)) +audited <- cbind(extract$sample, audit.value=audited) +# Evaluate the sample, cache and print it +evaluation <- MUS.evaluation(extract, audited) +MUS.binomial.bound(evaluation) + +} +\keyword{MUS} +\keyword{audit} diff --git a/man/MUS.calc.n.conservative.Rd b/man/MUS.calc.n.conservative.Rd new file mode 100644 index 0000000..9f07d83 --- /dev/null +++ b/man/MUS.calc.n.conservative.Rd @@ -0,0 +1,28 @@ +\encoding{UTF-8} +\name{MUS.calc.n.conservative} +\alias{MUS.calc.n.conservative} +\title{Calculate a conservative sample size.} +\description{ + Calculate a conservative sample size (AICPA, 2012). + Based on Technical Notes on the AICPA Audit Guide Audit Sampling, Trevor Stewart, AICPA, 2012. +} +\usage{ + MUS.calc.n.conservative(confidence.level, tolerable.error, expected.error, book.value) +} +\arguments{ + \item{confidence.level}{dito.} + \item{tolerable.error}{Tolerable error in monetary units.} + \item{expected.error}{Expected error in monetary units.} + \item{book.value}{Book value in monetary units.} +} +\value{ + Returns the (conservative) sample size. +} +\author{Andre Guimaraes } +\examples{ + +MUS.calc.n.conservative(0.95, 100000, 50000, 10000000) + +} +\keyword{MUS} +\keyword{audit} diff --git a/man/MUS.combine.Rd b/man/MUS.combine.Rd new file mode 100644 index 0000000..cf5ec5b --- /dev/null +++ b/man/MUS.combine.Rd @@ -0,0 +1,35 @@ +\encoding{UTF-8} +\name{MUS.combine} +\alias{MUS.combine} +\title{Combine MUS objects (joining strata into a full set).} +\description{ + Combine a list of MUS objects into a single object. + Typical use case is to group multiple strata into a single object. + Works with MUS.planning.result, MUS.extraction.result and MUS.evaluation.result objects. +} +\usage{ + MUS.combine(object.list) +} +\arguments{ + \item{object.list}{A list of MUS.planning.result, MUS.extraction.result and MUS.evaluation.result objects.} +} +\value{ + An object of the same type of the first item in the list is returned containing an aggregation of the objects in the list. +} +\author{Andre Guimaraes } +\examples{ + +## Simple Example +# Assume 500 invoices, each between 1 and 1000 monetary units +stratum.1 <- data.frame(book.value=round(runif(n=500, min=1, max=1000))) +plan.1 <- MUS.planning(data=stratum.1, tolerable.error=100000, expected.error=20000) + +stratum.2 <- data.frame(book.value=round(runif(n=500, min=1, max=1000))) +plan.2 <- MUS.planning(data=stratum.2, tolerable.error=100000, expected.error=20000) + +plan.combined <- MUS.combine(list(plan.1, plan.2)) + +print(plan.combined) +} +\keyword{MUS} +\keyword{audit} diff --git a/man/MUS.combined.high.error.rate.Rd b/man/MUS.combined.high.error.rate.Rd new file mode 100644 index 0000000..883c2fb --- /dev/null +++ b/man/MUS.combined.high.error.rate.Rd @@ -0,0 +1,56 @@ +\encoding{UTF-8} +\name{MUS.combined.high.error.rate} +\alias{MUS.combined.high.error.rate} +\title{Calculate a high error rate bound for a combined Monetary Unit Sampling evaluation.} +\description{ + Calculate a high error rate bound for a combined Monetary Unit Sampling evaluation. + + Please treat as experimental. +} +\usage{ + MUS.combined.high.error.rate(evaluation, interval.type) +} +\arguments{ + \item{evaluation}{A MUS.evaluation.result object used to calculate the combined bound.} + \item{interval.type}{Optional. Interval type for high error rate evaluation. Default is "one-sided".} +} +\value{ + Upper Error Limit calculed using high error rate evaluation for a combined sample. +} +\author{Andre Guimaraes } +\seealso{ + \code{\link{MUS.evaluation}} for evaluation of the audited sample. + \code{\link{MUS.combine}} for combining multiple evaluations. +} +\examples{ + +# Assume 500 invoices, each between 1 and 1000 monetary units +data1 <- data.frame(book.value=round(runif(n=500, min=1, max=1000))) +# Plan a sample and cache it +plan1 <- MUS.planning(data=data1, tolerable.error=10000, expected.error=2000) +# Extract a sample and cache it (no high values exist in this example) +extract1 <- MUS.extraction(plan1) +# Copy book value into a new column audit values, and inject some error +audited1 <- extract1$sample$book.value*(1-rbinom(nrow(extract1$sample), 1, 0.05)) +audited1 <- cbind(extract1$sample, audit.value=audited1) +# Evaluate the sample, cache and print it +evaluation1 <- MUS.evaluation(extract1, audited1) + +# Assume 500 invoices, each between 1 and 1000 monetary units +data2 <- data.frame(book.value=round(runif(n=500, min=1, max=1000))) +# Plan a sample and cache it +plan2 <- MUS.planning(data=data2, tolerable.error=10000, expected.error=2000) +# Extract a sample and cache it (no high values exist in this example) +extract2 <- MUS.extraction(plan2) +# Copy book value into a new column audit values, and inject some error +audited2 <- extract2$sample$book.value*(1-rbinom(nrow(extract2$sample), 1, 0.05)) +audited2 <- cbind(extract2$sample, audit.value=audited2) +# Evaluate the sample, cache and print it +evaluation2 <- MUS.evaluation(extract2, audited2) + +combined <- MUS.combine(list(evaluation1, evaluation2)) +MUS.combined.high.error.rate(combined) + +} +\keyword{MUS} +\keyword{audit} diff --git a/man/MUS.evaluation.Rd b/man/MUS.evaluation.Rd index 1c9b5c8..41d128d 100644 --- a/man/MUS.evaluation.Rd +++ b/man/MUS.evaluation.Rd @@ -11,7 +11,9 @@ } \usage{ MUS.evaluation(extract, filled.sample, filled.high.values, -col.name.audit.values, col.name.riskweights) +col.name.audit.values, col.name.riskweights, +interval.type, print.advice, tainting.order, +experimental, combined) } \arguments{ \item{extract}{A MUS.extraction.result object that you got by executing the @@ -29,6 +31,11 @@ col.name.audit.values, col.name.riskweights) column containing the risk weights in filled.sample respectively filled.high.values. Default is NULL, then no risk weights are included in the calcualations (the ordinary MUS case).} + \item{interval.type}{Interval type for high error rate evaluation. Default is "one-sided".} + \item{print.advice}{Boolean. Prints recommendations only if TRUE. Default is "TRUE".} + \item{tainting.order}{Calculates UEL with different tainting orders (increasing, absolute, random). Default is "decreasing".} + \item{experimental}{Boolean. Calculates other bounds, such as momentum, binomial, multinomial. Not ready for production. Default is "FALSE".} + \item{combined}{Boolean. Marks the dataset as a combination of multiple strata. Default is "FALSE".} } \value{ An object MUS.evaluation.result is returned which is a list containing diff --git a/man/MUS.extend.Rd b/man/MUS.extend.Rd new file mode 100644 index 0000000..ed5eb69 --- /dev/null +++ b/man/MUS.extend.Rd @@ -0,0 +1,51 @@ +\encoding{UTF-8} +\name{MUS.extend} +\alias{MUS.extend} +\title{Extend a MUS sample.} +\description{ + Extends a sample that requires further evidence. + Works with MUS.extraction.result. + + Please treat as experimental. +} +\usage{ + MUS.extend(extract, new_plan=NULL, additional.n=NULL) +} +\arguments{ + \item{extract}{An object of the type MUS.extraction.result to be extended.} + \item{new_plan}{Provide a new MUS plan. If null, you must provide the qty of items to extend the sample.} + \item{additional.n}{Ignored if new_plan is provided, otherwise sample will be extended by additional.n items} +} +\value{ + Returns an extended MUS.extraction.result object. +} +\author{Andre Guimaraes } +\examples{ + +## Simple Example +# Assume 500 invoices +mydata <- data.frame(book.value= + round(c(runif(n=480, min=10,max=20000), + runif(n=20, min=15000,max=50000))) +) + +# Plan a sample and cache it +plan <- MUS.planning(data=mydata, +tolerable.error=50000, expected.error=3000) + +# Extract a sample and cache it +extract <- MUS.extraction(plan, obey.n.as.min=TRUE) + +# Create a new plan +new_plan <- MUS.planning(data=mydata, +tolerable.error=50000, expected.error=5000) + +# extends the sample using the new plan +extended <- MUS.extend(extract, new_plan) + +# extends the sample by 20 itens using the original plan +extended20 <- MUS.extend(extract, additional.n=20) + +} +\keyword{MUS} +\keyword{audit} diff --git a/man/MUS.extraction.Rd b/man/MUS.extraction.Rd index 051d638..205aa9c 100644 --- a/man/MUS.extraction.Rd +++ b/man/MUS.extraction.Rd @@ -7,7 +7,7 @@ extraction step, you get to know the items that you have to audit. } \usage{ -MUS.extraction(plan, start.point, seed, obey.n.as.min) +MUS.extraction(plan, start.point, seed, obey.n.as.min, combined) } \arguments{ \item{plan}{A MUS.planning.result object that you got by executing the @@ -21,11 +21,12 @@ MUS.extraction(plan, start.point, seed, obey.n.as.min) number generator is initialised. This argument is mainly used for simulations or if you want to be able to regenerate the sample on another computer.} - \item{obey.n.as.min}{If set to TRUE, the sample interval will be + \item{obey.n.as.min}{Boolean. If set to TRUE, the sample interval will be exactly recalculated and thus the sample size will be exactly the planned sample size. Default is FALSE which is what most commercial statistical software do. In this case the drawn sample size might be slightly smaller than specified.} + \item{combined}{Boolean. Marks the dataset as a combination of multiple strata. Default is "FALSE".} } \value{ An object MUS.extraction.result is returned which is a list containing @@ -46,7 +47,7 @@ MUS.extraction(plan, start.point, seed, obey.n.as.min) } \author{Henning Prömpers } \seealso{ - \code{\link{MUS.planning}} for planning a sample and + \code{\link{MUS.planning}} for planning a sample and \code{\link{MUS.evaluation}} for evaluation of the extracted and audited sample. } diff --git a/man/MUS.factor.Rd b/man/MUS.factor.Rd new file mode 100644 index 0000000..2eee1cf --- /dev/null +++ b/man/MUS.factor.Rd @@ -0,0 +1,26 @@ +\encoding{UTF-8} +\name{MUS.factor} +\alias{MUS.factor} +\title{Calculate MUS Factor.} +\description{ + Calculate MUS Factor (AICPA, 2012). + Based on Technical Notes on the AICPA Audit Guide Audit Sampling, Trevor Stewart, AICPA, 2012. +} +\usage{ + MUS.factor(confidence.level, pct.ratio) +} +\arguments{ + \item{confidence.level}{dito.} + \item{pct.ratio}{Expected.error by tolerable.error.} +} +\value{ + Returns the MUS factor. +} +\author{Andre Guimaraes } +\examples{ + +MUS.factor(0.95, 0.5) + +} +\keyword{MUS} +\keyword{audit} diff --git a/man/MUS.moment.bound.Rd b/man/MUS.moment.bound.Rd new file mode 100644 index 0000000..fc49d8a --- /dev/null +++ b/man/MUS.moment.bound.Rd @@ -0,0 +1,46 @@ +\encoding{UTF-8} +\name{MUS.moment.bound} +\alias{MUS.moment.bound} +\title{Calculate the moment bound for a Monetary Unit Sampling evaluation.} +\description{ + Calculates the moment bound (Dworkin & Grimlund, 1984) for a Monetary Unit Sampling evaluation. + + Please treat as experimental. +} +\usage{ + MUS.moment.bound(x, confidence.level, as.pct, include.high.values) +} +\arguments{ + \item{x}{A MUS.evaluation.result object (or a tainting vector) used to calculate the moment bound.} + \item{confidence.level}{The required confidence level. Default is 95\%.} + \item{as.pct}{Boolean. Express results as percentage. Default is False.} + \item{include.high.values}{Boolean. Whether the bound should include high values. Default is "TRUE".} +} +\value{ + Upper Error Limit calculed using the moment bound. +} +\author{Andre Guimaraes } +\seealso{ + \code{\link{MUS.evaluation}} for evaluation of the audited sample. +} +\examples{ + +sample = c(rep(0, 96), -.16, .04, .18, .47) +MUS.moment.bound(sample) + +# Assume 500 invoices, each between 1 and 1000 monetary units +data <- data.frame(book.value=round(runif(n=500, min=1, max=1000))) +# Plan a sample and cache it +plan <- MUS.planning(data=data, tolerable.error=10000, expected.error=2000) +# Extract a sample and cache it (no high values exist in this example) +extract <- MUS.extraction(plan) +# Copy book value into a new column audit values, and inject some error +audited <- extract$sample$book.value*(1-rbinom(nrow(extract$sample), 1, 0.05)) +audited <- cbind(extract$sample, audit.value=audited) +# Evaluate the sample, cache and print it +evaluation <- MUS.evaluation(extract, audited) +MUS.moment.bound(evaluation) + +} +\keyword{MUS} +\keyword{audit} diff --git a/man/MUS.multinomial.bound.Rd b/man/MUS.multinomial.bound.Rd new file mode 100644 index 0000000..3d56aea --- /dev/null +++ b/man/MUS.multinomial.bound.Rd @@ -0,0 +1,42 @@ +\encoding{UTF-8} +\name{MUS.multinomial.bound} +\alias{MUS.multinomial.bound} +\title{Calculate a multinomial bound for a Monetary Unit Sampling evaluation.} +\description{ + Calculates a multinomial bound for a Monetary Unit Sampling evaluation. + + Please treat as experimental. +} +\usage{ + MUS.multinomial.bound(x, as.pct, include.high.values) +} +\arguments{ + \item{x}{A MUS.evaluation.result object used to calculate the multinomial bound.} + \item{as.pct}{Boolean. Express results as percentage. Default is False.} + \item{include.high.values}{Boolean. Whether the bound should include high values. Default is "TRUE".} +} +\value{ + Upper Error Limit calculed using the multinomial bound. +} +\author{Andre Guimaraes } +\seealso{ + \code{\link{MUS.evaluation}} for evaluation of the audited sample. +} +\examples{ + +# Assume 500 invoices, each between 1 and 1000 monetary units +data <- data.frame(book.value=round(runif(n=500, min=1, max=1000))) +# Plan a sample and cache it +plan <- MUS.planning(data=data, tolerable.error=10000, expected.error=2000) +# Extract a sample and cache it (no high values exist in this example) +extract <- MUS.extraction(plan) +# Copy book value into a new column audit values, and inject some error +audited <- extract$sample$book.value*(1-rbinom(nrow(extract$sample), 1, 0.05)) +audited <- cbind(extract$sample, audit.value=audited) +# Evaluate the sample, cache and print it +evaluation <- MUS.evaluation(extract, audited) +MUS.multinomial.bound(evaluation) + +} +\keyword{MUS} +\keyword{audit} diff --git a/man/MUS.planning.Rd b/man/MUS.planning.Rd index 19701e3..fd86e04 100644 --- a/man/MUS.planning.Rd +++ b/man/MUS.planning.Rd @@ -11,7 +11,7 @@ } \usage{ MUS.planning(data, col.name.book.values, confidence.level, -tolerable.error, expected.error, n.min) +tolerable.error, expected.error, n.min, errors.as.pct, conservative, combined) } \arguments{ \item{data}{A data frame or matrix which contains at least one column @@ -25,6 +25,10 @@ tolerable.error, expected.error, n.min) \item{expected.error}{The expected error which is contained in the population in Monetary Units.} \item{n.min}{Minimum sample size that should be used. Default is 0.} + \item{errors.as.pct}{Boolean. Tolerable and Expected error informed as percentages. Default is False.} + \item{conservative}{Boolean. If true, use greater sample size between normal calculation and + conservative algorithm (i.e., gamma-based, AICPA compatible).} + \item{combined}{Boolean. Marks the dataset as a combination of multiple strata. Default is "FALSE".} } \value{ An object MUS.planning.result is returned which is a list containing @@ -41,14 +45,14 @@ tolerable.error, expected.error, n.min) which is greater or egal than the provided minimum sample size.} \item{High.value.threshold}{Whenever a book value of an element is above the threshold, the element will be considered individually - significant. Individual significant items will be audited completely, - no sample extrapolation will be necessary.} + significant. Individual significant items will be audited completely, + no sample extrapolation will be necessary.} \item{tolerable.taintings}{The number of taintings in the sample that will be acceptable at maximum.} } \author{Henning Prömpers } \seealso{ - \code{\link{MUS.extraction}} for extraction of the planned sample and + \code{\link{MUS.extraction}} for extraction of the planned sample and \code{\link{MUS.evaluation}} for evaluation of the extracted and audited sample. } diff --git a/man/print.MUS.evaluation.result.Rd b/man/print.MUS.evaluation.result.Rd index 5fa9068..62de4d6 100644 --- a/man/print.MUS.evaluation.result.Rd +++ b/man/print.MUS.evaluation.result.Rd @@ -7,11 +7,21 @@ be used for working papers. } \usage{ -\method{print}{MUS.evaluation.result}(x, ...) +\method{print}{MUS.evaluation.result}(x, error.rate, print.misstatements, + print.planning, print.extraction, print.error.as.pct, print.advice, + style, use.pander, ...) } \arguments{ \item{x}{A MUS.evaluation.result object that you got by executing the function MUS.evaluation.} + \item{error.rate}{Selects type of error rate calculation (i.e., "high", "low", "both" or "auto"). Defaults to "auto".} + \item{print.misstatements}{Boolean. Should misstatements table be printed? Defaults to TRUE.} + \item{print.planning}{Boolean. Should planning parameters be printed? Defaults to FALSE.} + \item{print.extraction}{Boolean. Should extraction parameters be printed? Defaults to FALSE.} + \item{print.error.as.pct}{Boolean. Should errors as percentage be printed? Defaults to TRUE.} + \item{print.advice}{Boolean. Should recommendations be printed? Defaults to TRUE.} + \item{style}{Two options: "report" or "default". Report uses an alternative layout. Defaults to "default".} + \item{use.pander}{Boolean. Uses pander to generate rmarkdown report. Defaults to FALSE.} \item{...}{Further arguments, currently ignored.} } \author{Henning Prömpers } diff --git a/man/print.MUS.extraction.result.Rd b/man/print.MUS.extraction.result.Rd new file mode 100644 index 0000000..0259cd6 --- /dev/null +++ b/man/print.MUS.extraction.result.Rd @@ -0,0 +1,28 @@ +\encoding{UTF-8} +\name{print.MUS.extraction.result} +\alias{print.MUS.extraction.result} +\title{Pretty and comprehensive printing of MUS extraction results} +\description{ + Pretty and comprehensive printing of MUS extraction results that can + be used for working papers. +} +\usage{ +\method{print}{MUS.extraction.result}(x, print.title, + print.planning, style, use.pander, ...) +} + +\arguments{ + \item{x}{A MUS.evaluation.result object that you got by executing the + function MUS.evaluation.} + \item{print.title}{Boolean. Should title be printed? Defaults to TRUE.} + \item{print.planning}{Boolean. Should planning parameters be printed? Defaults to FALSE.} + \item{style}{Two options: "report" or "default". Report uses an alternative layout. Defaults to "default".} + \item{use.pander}{Boolean. Uses pander to generate rmarkdown report. Defaults to FALSE.} + \item{...}{Further arguments, currently ignored.} +} +\author{Henning Prömpers } +\seealso{ + \code{\link{MUS.extraction}} for extraction of the audit sample. +} +\keyword{MUS} +\keyword{audit} diff --git a/man/print.MUS.planning.result.Rd b/man/print.MUS.planning.result.Rd new file mode 100644 index 0000000..b2b18ea --- /dev/null +++ b/man/print.MUS.planning.result.Rd @@ -0,0 +1,27 @@ +\encoding{UTF-8} +\name{print.MUS.planning.result} +\alias{print.MUS.planning.result} +\title{Pretty and comprehensive printing of MUS planning results} +\description{ + Pretty and comprehensive printing of MUS planning results that can + be used for working papers. +} +\usage{ +\method{print}{MUS.planning.result}(x, print.title, + style, use.pander, ...) +} + +\arguments{ + \item{x}{A MUS.evaluation.result object that you got by executing the + function MUS.evaluation.} + \item{print.title}{Boolean. Should title be printed? Defaults to TRUE.} + \item{style}{Two options: "report" or "default". Report uses an alternative layout. Defaults to "default".} + \item{use.pander}{Boolean. Uses pander to generate rmarkdown report. Defaults to FALSE.} + \item{...}{Further arguments, currently ignored.} +} +\author{Henning Prömpers } +\seealso{ + \code{\link{MUS.planning}} for planning of the audit sample. +} +\keyword{MUS} +\keyword{audit} diff --git a/po/R-MUS.pot b/po/R-MUS.pot new file mode 100644 index 0000000..fa9b6bc --- /dev/null +++ b/po/R-MUS.pot @@ -0,0 +1,438 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: MUS 0.1.5\n" +"Report-Msgid-Bugs-To: https://github.com/alsguimaraes/MUS\n" +"POT-Creation-Date: 2017-11-17 19:07-0200\n" +"PO-Revision-Date: 2017-10-20 15:22\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: ll\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.4\n" + +msgid "" +"x has to be a vector or an object of type MUS.evaluation.result. Use " +"function MUS.evaluate to create such an object." +msgstr "" + +msgid "" +"x has to be an object from type MUS.evaluation.result. Use function MUS." +"evaluate to create such an object." +msgstr "" + +msgid "" +"object.list must be a list with one or more MUS.evaluation.result objects." +msgstr "" + +msgid "" +"extract has to be an object from type MUS.extraction.result. Use function " +"MUS.extraction to create such an object." +msgstr "" + +msgid "" +"col.name.audit.values has to be a single character value (default book." +"value)." +msgstr "" + +msgid "" +"col.name.riskweights has to be NULL if no risk weights are used (as in " +"ordinary MUS) or a single character value (default NULL)." +msgstr "" + +msgid "filled.sample needs to be a data frame or a matrix but it is not." +msgstr "" + +msgid "" +"The filled.sample requires a column with the book values and the name of " +"this column has to be provided by parameter col.name.book.values during MUS." +"planning (default book.value)." +msgstr "" + +msgid "" +"The filled.sample requires a column with the audit values and the name of " +"this column has to be provided by parameter col.name.audit.values (default " +"audit.value)." +msgstr "" + +msgid "" +"If col.name.riskweights is not NULL, the filled.sample requires a column " +"with the col.name.riskweights and the name of this column has to be provided " +"by parameter col.name.riskweights (default NULL)." +msgstr "" + +msgid "" +"filled.sample must not have a column 'd' because this column name is used " +"for internal evaluation." +msgstr "" + +msgid "" +"filled.sample must not have a column 'tord' because this column name is used " +"for internal evaluation." +msgstr "" + +msgid "filled.high.values needs to be a data frame or a matrix but it is not." +msgstr "" + +msgid "" +"The filled.high.values requires a column with the book values and the name " +"of this column has to be provided by parameter col.name.book.values during " +"MUS.planning (default book.value)." +msgstr "" + +msgid "" +"The filled.high.values requires a column with the audit values and the name " +"of this column has to be provided by parameter col.name.audit.values " +"(default audit.value)." +msgstr "" + +msgid "" +"If col.name.riskweights is not NULL, the filled.high.values requires a " +"column with the col.name.riskweights and the name of this column has to be " +"provided by parameter col.name.riskweights (default NULL)." +msgstr "" + +msgid "**" +msgstr "" + +msgid "" +"You had at least 20 errors in the sample. High Error Rate evaluation " +"recommended." +msgstr "" + +msgid "" +"plan has to be an object from type MUS.planning.result. Use function MUS." +"planning to create such an object." +msgstr "" + +msgid "seed has to be an integer value greater or equal than 0." +msgstr "" + +msgid "obey.n.as.min has to be TRUE or FALSE." +msgstr "" + +msgid "" +"start.point has to be a numeric value between 0 and possible recalculated " +"interval length (both inclusive)." +msgstr "" + +msgid "Parameters must be between 0 and 1." +msgstr "" + +msgid "Data needs to be a data frame or a matrix but it is not." +msgstr "" + +msgid "" +"The data frame requires at least a column with the book values and the name " +"of this column has to be provided by parameter col.name.book.values (default " +"book.value)." +msgstr "" + +msgid "" +"There are missing or infinite values (NA, NaN or Inf) as book values in your " +"data. Those elements have no chance for selection. You have to audit them " +"separately." +msgstr "" + +msgid "" +"There are zeros as book values in your data. Those elements have no chance " +"for selection. You have to audit them separately." +msgstr "" + +msgid "" +"There are negative values as book values in your data. Those elements have " +"no chance for selection. You have to audit them separately." +msgstr "" + +msgid "" +"Confidence level has to be a numeric value between 0 and 1 (both exclusive)." +msgstr "" + +msgid "" +"Tolerable Error has to be a numeric value between 0 and book value (both " +"exclusive)." +msgstr "" + +msgid "Expected error has to be a numeric value greater or equal to 0." +msgstr "" + +msgid "" +"Minimum number of sample size has to be a numeric value between 0 and the " +"number of items in the population (last exclusive). If the minimum sample " +"size is equal or larger than the number of items in the population, sampling " +"is not suitable because every item has to be tested anyway." +msgstr "" + +msgid "Combination of parameters leads to impractically large sample." +msgstr "" + +msgid "" +"Tolerable Error has to be a numeric value between 0 and book value (both " +"exclusive). If the tolerable error is equal larger than book value, no " +"sampling is necessary. However, Planning will be proceeded." +msgstr "" + +msgid "" +"Undefined situation: If 0 errors in the sample occur, the sample size needs " +"to be positive!" +msgstr "" + +msgid "" +"MUS makes no sense for your sampling problem - your sample size needs to be " +"bigger than the number of items in your population." +msgstr "" + +msgid "" +"Just for information: If the expected error is equal or larger than te " +"tolerable error, MUS is not applicable." +msgstr "" + +msgid "" +"n.optimal is not plausible (negative), internal error, please report as bug." +msgstr "" + +msgid "" +"n.optimal is not plausible (smaller than lower bound ni), internal error, " +"please report as bug." +msgstr "" + +msgid "" +"n.optimal is not plausible (greater than upper bound nip1), internal error, " +"please report as bug." +msgstr "" + +msgid "Evaluation Results" +msgstr "" + +msgid "No misstatements found. Thus, the projected misstatememt is 0." +msgstr "" + +msgid "Audited Misstatements" +msgstr "" + +msgid "Audited Overstatements" +msgstr "" + +msgid "Audited Understatements" +msgstr "" + +msgid "Sample Misstatements" +msgstr "" + +msgid "High Value Misstatements" +msgstr "" + +msgid "UEL (Low Error Rate)" +msgstr "" + +msgid "UEL (High Error Rate)" +msgstr "" + +msgid "Upper Error Limit (Final)" +msgstr "" + +msgid "Most Likely Error" +msgstr "" + +msgid "MLE (Low Error Rate)" +msgstr "" + +msgid "MLE (High Error Rate)" +msgstr "" + +msgid "Description" +msgstr "" + +msgid "Items" +msgstr "" + +msgid "Value" +msgstr "" + +msgid "Number of Overstatements" +msgstr "" + +msgid "Number of Understatements" +msgstr "" + +msgid "Sample Misstatement Amount" +msgstr "" + +msgid "High Values Misstatement Amount" +msgstr "" + +msgid "Audited Misstatement Amount" +msgstr "" + +msgid "Tainting Order" +msgstr "" + +msgid "Upper Error Limit (Low Error Rate)" +msgstr "" + +msgid "Upper Error Limit (Overstatements)" +msgstr "" + +msgid "Upper Error Limit (Understatements)" +msgstr "" + +msgid "UEL Acceptable (Low Error Rate)" +msgstr "" + +msgid "Upper Error Limit (High Error Rate)" +msgstr "" + +msgid "UEL Acceptable (High Error Rate)" +msgstr "" + +msgid "Upper Error Limit (Moment Bound)" +msgstr "" + +msgid "Upper Error Limit (Binomial Bound)" +msgstr "" + +msgid "Upper Error Limit (Multinomial Bound)" +msgstr "" + +msgid "Factual Misstatements" +msgstr "" + +msgid "Some strata are acceptable." +msgstr "" + +msgid "No strata are acceptable." +msgstr "" + +msgid "You have to get further audit evidence or extend the sample." +msgstr "" + +msgid "You have to book the MLE if it is material." +msgstr "" + +msgid "Stratum results are not acceptable." +msgstr "" + +msgid "All strata results are acceptable." +msgstr "" + +msgid "Stratum results are acceptable." +msgstr "" + +msgid "Audit evidence is sufficient." +msgstr "" + +msgid "" +"You had less than 20 errors in the sample. Low Error Rate evaluation " +"recommended." +msgstr "" + +msgid "" +"Please be aware that MUS is not designed to detect understatements, thus " +"they can only be used as an indicator." +msgstr "" + +msgid "Recommendations" +msgstr "" + +msgid "Yes" +msgstr "" + +msgid "No" +msgstr "" + +msgid "" +"x has to be an object from type MUS.extraction.result or MUS.evaluation." +"result or MUS.planning.result." +msgstr "" + +msgid "Extraction Parameters" +msgstr "" + +msgid "Sample" +msgstr "" + +msgid "High Values" +msgstr "" + +msgid "Audited" +msgstr "" + +msgid "Population" +msgstr "" + +msgid "Sample items" +msgstr "" + +msgid "Sample amount" +msgstr "" + +msgid "Sample coverage" +msgstr "" + +msgid "High Value items" +msgstr "" + +msgid "High Value amount" +msgstr "" + +msgid "High Value coverage" +msgstr "" + +msgid "Audited items" +msgstr "" + +msgid "Audited amount" +msgstr "" + +msgid "Audited coverage" +msgstr "" + +msgid "Planning Parameters" +msgstr "" + +msgid "Expected Error" +msgstr "" + +msgid "Tolerable Error (Materiality)" +msgstr "" + +msgid "Confidence Level" +msgstr "" + +msgid "High Value Threshold" +msgstr "" + +msgid "Population size" +msgstr "" + +msgid "Population amount" +msgstr "" + +msgid "Expected Error in population" +msgstr "" + +msgid "Expected Error Rate" +msgstr "" + +msgid "Tolerable Error Rate" +msgstr "" + +msgid "Sample size" +msgstr "" + +msgid "Stratum" +msgstr "" + +msgid "strata" +msgstr "" + +msgid "MLE (Observed)" +msgstr "" + +msgid "MLE (Projected)" +msgstr "" + +msgid "MLE (Projection Rate)" +msgstr "" diff --git a/po/R-pt_BR.mo b/po/R-pt_BR.mo new file mode 100644 index 0000000..0f87c78 Binary files /dev/null and b/po/R-pt_BR.mo differ diff --git a/po/R-pt_BR.po b/po/R-pt_BR.po new file mode 100644 index 0000000..77eb599 --- /dev/null +++ b/po/R-pt_BR.po @@ -0,0 +1,362 @@ +msgid "" +msgstr "" +"Project-Id-Version: MUS 0.1.5\n" +"Report-Msgid-Bugs-To: https://github.com/alsguimaraes/MUS\n" +"POT-Creation-Date: 2017-10-20 15:22\n" +"PO-Revision-Date: 2017-11-17 19:07-0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.0.4\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +msgid "x has to be a vector or an object of type MUS.evaluation.result. Use function MUS.evaluate to create such an object." +msgstr "x deve ser um vetor ou objeto do tipo MUS.evaluation.result. Use a função MUS.evaluate para criar tal objeto." + +msgid "x has to be an object from type MUS.evaluation.result. Use function MUS.evaluate to create such an object." +msgstr "x deve ser um objeto do tipo MUS.evaluation.result. Use a função MUS.evaluate para criar tal objeto." + +msgid "object.list must be a list with one or more MUS.evaluation.result objects." +msgstr "lx deve ser uma lista com um ou mais objetos do tipo MUS.evaluation.result." + +msgid "extract has to be an object from type MUS.extraction.result. Use function MUS.extraction to create such an object." +msgstr "A extração (extract) deve ser um objeto do tipo MUS.extraction.result. Use a função MUS.extraction para criar tal objeto." + +msgid "col.name.audit.values has to be a single character value (default book.value)." +msgstr "A coluna de valores auditados (col.name.audit.values) deve ser do tipo caracter (default = book.value)." + +msgid "col.name.riskweights has to be NULL if no risk weights are used (as in ordinary MUS) or a single character value (default NULL)." +msgstr "Os pesos (col.name.riskweights) devem ser NULL (MUS padrão) ou caracter (default NULL)." + +msgid "filled.sample needs to be a data frame or a matrix but it is not." +msgstr "Amostra (filled.sample) deve ser um data frame ou matrix, mas não é." + +msgid "The filled.sample requires a column with the book values and the name of this column has to be provided by parameter col.name.book.values during MUS.planning (default book.value)." +msgstr "A amostra (filled.sample) requer uma coluna com valores (book values) e o nome da coluna no parâmetro col.name.book.values (default book.value) durante o planejamento (MUS.planning)." + +msgid "The filled.sample requires a column with the audit values and the name of this column has to be provided by parameter col.name.audit.values (default audit.value)." +msgstr "A amostra (filled.sample) requer uma coluna com os valores auditados e o nome da coluna no parâmetro col.name.audit.values (default audit.value)." + +msgid "If col.name.riskweights is not NULL, the filled.sample requires a column with the col.name.riskweights and the name of this column has to be provided by parameter col.name.riskweights (default NULL)." +msgstr "Se col.name.riskweights não é NULL (default NULL), a amostra (filled.sample) deve ter uma coluna (indicada em col.name.riskweights) com os pesos." + +msgid "filled.sample must not have a column 'd' because this column name is used for internal evaluation." +msgstr "a amostra (filled.sample) não deve ter uma coluna 'd', pois esse nome é usado internamente." + +msgid "filled.sample must not have a column 'tord' because this column name is used for internal evaluation." +msgstr "a amostra (filled.sample) não deve ter uma coluna 'tord', pois esse nome é usado internamente." + +msgid "filled.high.values needs to be a data frame or a matrix but it is not." +msgstr "Os valores altos da amostra (filled.high.values) deve ser data frame ou matriz." + +msgid "The filled.high.values requires a column with the book values and the name of this column has to be provided by parameter col.name.book.values during MUS.planning (default book.value)." +msgstr "Os valores altos da amostra requerem uma coluna com os valores informados (book values) e o nome da coluna indicado no parâmetro col.name.book.values (default book.value) durante o planejamento (MUS.planning)." + +msgid "The filled.high.values requires a column with the audit values and the name of this column has to be provided by parameter col.name.audit.values (default audit.value)." +msgstr "Os valores mais altos requerem uma coluna com valores auditados e nome da coluna indicado no parâmetro col.name.audit.values (default book.value)." + +msgid "If col.name.riskweights is not NULL, the filled.high.values requires a column with the col.name.riskweights and the name of this column has to be provided by parameter col.name.riskweights (default NULL)." +msgstr "Se o parâmetro col.name.riskweights não é NULL, os valores altos devem ser registrados em uma coluna indicada pelo parâmetro col.name.riskweights (default NULL)" + +msgid "**" +msgstr "**" + +msgid "You had at least 20 errors in the sample. High Error Rate evaluation recommended." +msgstr "Foram verificados pelo menos 20 erros na amostra - Avaliação High Error Rate recomendada." + +msgid "plan has to be an object from type MUS.planning.result. Use function MUS.planning to create such an object." +msgstr "o Plano (plan) deve ser um objeto do tipo MUS.planning.result. Use a função MUS.planning para criar tal objeto." + +msgid "seed has to be an integer value greater or equal than 0." +msgstr "a semente do gerador aleatório (seed) deve ser maior ou igual a 0." + +msgid "obey.n.as.min has to be TRUE or FALSE." +msgstr "o parâmetro obey.n.as.min deve ser TRUE ou FALSE." + +msgid "start.point has to be a numeric value between 0 and possible recalculated interval length (both inclusive)." +msgstr "o parâmetro start.point deve ser numérico entre 0 e o tamanho do intervalo recalculado (inclusive)." + +msgid "Parameters must be between 0 and 1." +msgstr "Parametros devem estar entre 0 e 1." + +msgid "Data needs to be a data frame or a matrix but it is not." +msgstr "Dados devem ser data frame ou matriz, mas não são." + +msgid "The data frame requires at least a column with the book values and the name of this column has to be provided by parameter col.name.book.values (default book.value)." +msgstr "O data frame requer ao menos uma coluna com valores informados e o nome da coluna indicado pelo parâmetro col.name.book.values (default book.value)." + +msgid "There are missing or infinite values (NA, NaN or Inf) as book values in your data. Those elements have no chance for selection. You have to audit them separately." +msgstr "Os dados contém valores faltantes ou infinitos (NA, NaN ou Inf) nos valores informados (book values). Tais elementos não serão selecionados e deverão ser auditados separadamente." + +msgid "There are zeros as book values in your data. Those elements have no chance for selection. You have to audit them separately." +msgstr "Os dados contém valores informados (book values) iguais a zero. Tais elementos não serão selecionados e deverão ser auditados separadamente." + +msgid "There are negative values as book values in your data. Those elements have no chance for selection. You have to audit them separately." +msgstr "Os dados contém valores informados (book values) negativos. Tais elementos não serão selecionados e deverão ser auditados separadamente." + +msgid "Confidence level has to be a numeric value between 0 and 1 (both exclusive)." +msgstr "O nível de confiança deve ser numérico entre 0 e 1 (exclusive)." + +msgid "Tolerable Error has to be a numeric value between 0 and book value (both exclusive)." +msgstr "O Erro Tolerável deve ser numérico entre 0 e 1 (exclusive)." + +msgid "Expected error has to be a numeric value greater or equal to 0." +msgstr "O Erro Esperado deve ser numérico entre 0 e 1 (exclusive)." + +msgid "Minimum number of sample size has to be a numeric value between 0 and the number of items in the population (last exclusive). If the minimum sample size is equal or larger than the number of items in the population, sampling is not suitable because every item has to be tested anyway." +msgstr "O tamanho da amostra mínimo deve ser entre 1 e o número de itens na população (exclusive). Se o tamanho da amostra for maior ou igual o número de itens na população, a amostragem não é aplicável pois todos os itens devem ser testados." + +msgid "Combination of parameters leads to impractically large sample." +msgstr "A combinação de parâmetros leva a uma amostra grande demais." + +msgid "Tolerable Error has to be a numeric value between 0 and book value (both exclusive). If the tolerable error is equal larger than book value, no sampling is necessary. However, Planning will be proceeded." +msgstr "O Erro Tolerável deve ser um valor numérico enter 0 e o valor informado (book value) - exclusive. Caso o erro tolerável seja maior que o valor informado, a amostragem não é necessária. Entretanto, o planejamento será executado." + +msgid "Undefined situation: If 0 errors in the sample occur, the sample size needs to be positive!" +msgstr "Situação indefinida: Se não há erros na amostra, o tamanho da amostra deve ser positivo!" + +msgid "MUS makes no sense for your sampling problem - your sample size needs to be bigger than the number of items in your population." +msgstr "MUS não se aplica ao problema - a amostra seria maior que o número de itens da população." + +msgid "Just for information: If the expected error is equal or larger than te tolerable error, MUS is not applicable." +msgstr "Observação: Se o erro esperado é maior ou igual ao erro tolerado, MUS não é aplicável." + +msgid "n.optimal is not plausible (negative), internal error, please report as bug." +msgstr "n.optimal não é plausível (negativo), erro interno, favor reportar como bug." + +msgid "n.optimal is not plausible (smaller than lower bound ni), internal error, please report as bug." +msgstr "n.optimal não é plausível (menor que o limite inferior ni), erro interno, favor reportar como bug." + +msgid "n.optimal is not plausible (greater than upper bound nip1), internal error, please report as bug." +msgstr "n.optimal não é plausível (maior que o limite superior nip1), erro interno, favor reportar como bug." + +msgid "Evaluation Results" +msgstr "Resultados da Avaliação" + +msgid "No misstatements found. Thus, the projected misstatememt is 0." +msgstr "Não foram encontradas distorções. Assim, a distorção projetada é 0" + +msgid "Audited Misstatements" +msgstr "Conjunto Auditado - Distorções" + +msgid "Audited Overstatements" +msgstr "Conjunto Auditado - Distorções Positivas" + +msgid "Audited Understatements" +msgstr "Conjunto Auditado - Distorções Negativas" + +msgid "Sample Misstatements" +msgstr "Amostra - Distorções" + +msgid "High Value Misstatements" +msgstr "Alto Valor - Distorções" + +msgid "UEL (Low Error Rate)" +msgstr "LSE (Baixa Taxa de Erros)" + +msgid "UEL (High Error Rate)" +msgstr "LSE (Alta Taxa de Erros)" + +msgid "Upper Error Limit (Final)" +msgstr "Limite Superior de Erro (Final)" + +msgid "Most Likely Error" +msgstr "Erro Mais Provável - EMP" + +msgid "MLE (Low Error Rate)" +msgstr "EMP (Baixa Taxa de Erros)" + +msgid "MLE (High Error Rate)" +msgstr "EMP (Alta Taxa de Erros)" + +msgid "Description" +msgstr "Descrição" + +msgid "Items" +msgstr "Itens" + +msgid "Value" +msgstr "Valor" + +msgid "Number of Overstatements" +msgstr "Número de Distorções Positivas" + +msgid "Number of Understatements" +msgstr "Número de Distorções Negativas" + +msgid "Sample Misstatement Amount" +msgstr "Amostra - Valor das Distorções" + +msgid "High Values Misstatement Amount" +msgstr "Alto Valor - Valor das Distorções" + +msgid "Audited Misstatement Amount" +msgstr "Conjunto Auditado - Valor das Distorções" + +msgid "Tainting Order" +msgstr "Ordem de Desvios (Tainting)" + +msgid "Upper Error Limit (Low Error Rate)" +msgstr "Limite Superior do Erro (Baixa Taxa de Erros)" + +msgid "Upper Error Limit (Overstatements)" +msgstr "LSE (Distorções Positivas)" + +msgid "Upper Error Limit (Understatements)" +msgstr "LSE (Distorções Negativas)" + +msgid "UEL Acceptable (Low Error Rate)" +msgstr "LSE Aceitável (Baixa Taxa de Erros)" + +msgid "Upper Error Limit (High Error Rate)" +msgstr "Limite Superior do Erro (Alta Taxa de Erros)" + +msgid "UEL Acceptable (High Error Rate)" +msgstr "LSE Aceitável (Alta Taxa de Erros)" + +msgid "Upper Error Limit (Moment Bound)" +msgstr "Limite Superior do Erro (Moment Bound)" + +msgid "Upper Error Limit (Binomial Bound)" +msgstr "Limite Superior do Erro (Binomial Bound)" + +msgid "Upper Error Limit (Multinomial Bound)" +msgstr "Limite Superior do Erro (Multinomial Bound)" + +msgid "Factual Misstatements" +msgstr "Distorções Encontradas" + +msgid "Some strata are acceptable." +msgstr "Alguns estratos são aceitáveis." + +msgid "No strata are acceptable." +msgstr "Nenhum estrato é aceitável." + +msgid "You have to get further audit evidence or extend the sample." +msgstr "São necessárias mais evidências ou uma amostra maior." + +msgid "You have to book the MLE if it is material." +msgstr "O erro mais provável deve ser ajustado." + +msgid "Stratum results are not acceptable." +msgstr "Resultados do estrato não são aceitáveis." + +msgid "All strata results are acceptable." +msgstr "Resultados de todos os estratos são aceitáveis." + +msgid "Stratum results are acceptable." +msgstr "Resultados do estrato são aceitáveis." + +msgid "Audit evidence is sufficient." +msgstr "As evidências são suficientes." + +msgid "You had less than 20 errors in the sample. Low Error Rate evaluation recommended." +msgstr "Menos de 20 erros na amostra. Avaliação com Baixa Taxa de Erros recomendada." + +msgid "Please be aware that MUS is not designed to detect understatements, thus they can only be used as an indicator." +msgstr "Note que MUS não é desenhado para detectar distorções negativas, estas devem ser usadas apenas como indicador." + +msgid "Recommendations" +msgstr "Recomendações" + +msgid "Yes" +msgstr "Sim" + +msgid "No" +msgstr "Não" + +msgid "x has to be an object from type MUS.extraction.result or MUS.evaluation.result or MUS.planning.result." +msgstr "x deve ser um objeto de tipo MUS.extraction.result ou MUS.evaluation.result ou MUS.planning.result." + +msgid "Extraction Parameters" +msgstr "Parâmetros de Extração" + +msgid "Sample" +msgstr "Amostra" + +msgid "High Values" +msgstr "Alto Valor" + +msgid "Audited" +msgstr "Conjunto Auditado" + +msgid "Population" +msgstr "População" + +msgid "Sample items" +msgstr "Amostra - itens" + +msgid "Sample amount" +msgstr "Amostra - valor" + +msgid "Sample coverage" +msgstr "Amostra - cobertura" + +msgid "High Value items" +msgstr "Alto Valor - itens" + +msgid "High Value amount" +msgstr "Alto Valor - valor" + +msgid "High Value coverage" +msgstr "Alto Valor - cobertura" + +msgid "Audited items" +msgstr "Conjunto Auditado - itens" + +msgid "Audited amount" +msgstr "Conjunto Auditado - valor" + +msgid "Audited coverage" +msgstr "Conjunto Auditado - cobertura" + +msgid "Planning Parameters" +msgstr "Parâmetros de Planejamento" + +msgid "Expected Error" +msgstr "Erro Esperado" + +msgid "Tolerable Error (Materiality)" +msgstr "Erro Tolerável (Materialidade)" + +msgid "Confidence Level" +msgstr "Nível de Confiança" + +msgid "High Value Threshold" +msgstr "Corte Alto Valor" + +msgid "Population size" +msgstr "Tamanho da População" + +msgid "Population amount" +msgstr "Valor da População" + +msgid "Expected Error in population" +msgstr "Erro Esperado na População" + +msgid "Expected Error Rate" +msgstr "Taxa de Erro Esperado" + +msgid "Tolerable Error Rate" +msgstr "Taxa de Erro Tolerável" + +msgid "Sample size" +msgstr "Tamanho da Amostra" + +msgid "strata" +msgstr "estratos" + +msgid "Stratum" +msgstr "Estrato" + +msgid "MLE (Observed)" +msgstr "EMP (Observado)" + +msgid "MLE (Projected)" +msgstr "EMP (Projetado)" + +msgid "MLE (Projection Rate)" +msgstr "EMP (Pct. Projeção)"