Benford's law 1st 2 digit test

Background: 

This will perform the Benford 1st 2 digit test on each distinct item in a selected column.  So if you have a vendor column this would perform the test for each vendor.  It allows you to exclude low value items.

Updated for IDEA v9 on Feb 14, 2013.

Documentation: 

IDEAScript :      Benford First Two Digits.iss

' Author :           Brian Element , Sunder Gee, Steve Luciani

' Date :              March 22, 2012

' Purpose :        This test will create a file of first two digit analysis based on a field and amount

'                       optioned through a menu.

'Modified:         Aug 1, 2012 - Updated the equation for the Expected field using the Log10

'                       function as outlined on page 87 of Forensic Analytics by Mark Nigrini, PhD

'*****************************************************************************************************

This test is based on the Benford's Law First Two Digits test.  The test within IDEA performs the First Two Digits test on the entire file.  This script allows you to perform the same test but based on a field within the population.  As an example, if you have a vendor field, this test would perform the First Two Digits test on all transactions for each vendor.  This should allow the auditor to look for vendors that might have payments that do not fit the First Two Digits test.  It is recommended that you only look at vendors that have a large number of transactions as small size populations may give inconsistent results.

 

How to use the script.

 

When you start the script you will have the following dialog.  In this dialog you will select the file you wish to run the analysis on, the Client Field which is the field you want to test, so if you are running this tests on vendor information you would select the field that contains the vendor, the Amount Field is the field in which you want to run the first digit test on, this would be a numeric field and usually would be the amount.  The optional fields allow you to select additional fields that you may want to have added to your analysis, the optional fields works in the same was as when you select optional fields from within the IDEA summary function.  You can also select the number of transactions per client, so if you are using this on a vendor file and you select 1000 you would only perform this analysis on vendors that have more than 1000 transactions in the file.  It is recommended that you don't perform this on clients with few transactions as the results will not fit Benford's law.  Finally you can run this on either positive or negative values.

 

 

 

 

The following file will be created.

 

 

 

The first field is your client field that was selected from the dialog.  The second field is the first two digits from the amount field which you selected.  The third field is the total number of records for this vendor.  The actual field is the actual number of digits for this vendor.  So in the first line there are 161 records where the amount starts with a 10 for vendor 2001.  The 5th field is the expected number of records based on Benford's law.  The six field is the difference between the actual and the expected and the final field is the percentage difference between the actual and the expected.

 

A history entry is also written for this analysis.