Benford's law 1st digit test

Background: 

This will perform the Benford 1st 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.

September 2015 - The interface has been rewritten along with some updates. 

Documentation: 

' IDEAScript :  Benford First Digit.iss
' Author :  Brian Element (brian.element@ideascripting.com)
' Date :   January 21, 2012
' Purpose :  This test will create a file of first digit analysis based on a field and amount
'  optioned thorugh a menu.
'Modified: March 19, 2012 - Added a routine in case the FIRST_DIGIT field exists, also
'  made the extraction more efficient as only extracting necessary fields
'*****************************************************************************************************
This test is based on the Benford's Law First Digits test.  The test within IDEA performs the First 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 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 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.  It is recommended that you only perform this on amounts greater or equal to 10 but the script does allow you to run it on amounts greater than or equal to 1 if this item is unticked.  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 digit 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 1,014 records where the amount starts with a 1 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.