# Load the jfa package
library(jfa)
#################################
### Example 1: Audit sampling ###
#################################
# Load the BuildIt population
data('BuildIt')
# Stage 1: Planning
stage1 <- planning(materiality = 0.03, expected = 0.01)
summary(stage1)
# Stage 2: Selection
stage2 <- selection(data = BuildIt, size = stage1,
units = 'values', values = 'bookValue',
method = 'interval', start = 1)
summary(stage2)
# Stage 3: Execution
sample <- stage2[['sample']]
# Stage 4: Evaluation
stage4 <- evaluation(data = sample, method = 'stringer.binomial',
values = 'bookValue', values.audit = 'auditValue')
summary(stage4)
#################################
### Example 2: Data auditing ####
#################################
# Load the sinoForest data set
data('sinoForest')
# Test first digits in the data against Benford's law
digit_test(sinoForest[["value"]], check = "first", reference = "benford")
######################################
### Example 3: Algorithm auditing ####
######################################
# Load the compas data set
data('compas')
# Test algorithmic fairness against Caucasian ethnicity
model_fairness(compas, "Ethnicity", "TwoYrRecidivism", "Predicted",
privileged = "Caucasian", positive = "yes")
Run the code above in your browser using DataLab