SPSS Statistics

 View Only

Benford's Law Extension for SPSS Statistics

By Douglas Stauber posted Tue April 05, 2016 03:51 PM

A few years ago, I learned about an interesting mathematical phenomenon known as Benford’s law, or the first digit law. The law states that most “natural” numbers begin with the number 1, followed by 2, followed by 3, and so on. There are many great blog posts and videos that do a good job of explaining this (see Wikipedia, Wolfram, or this video). Note that a cool application of Benford’s Law is in fraud detection.

IBM SPSS Statistics 24 makes it easy to build extensions based on R, Python, or SPSS syntax, so I decided to write a quick extension that graphs the distribution of a variable’s most significant digit and compares it to the “pure” value as calculated by Benford’s Law.

Screen Shot 2016-03-25 at 4.39.40 PM

As an example, I used the extension to plot country populations in 2014 (blue bars) with the Benford’s Law prediction (green line). Country populations seem to hold up to Benford’s Law quite well.


Download the extension for free today by navigating to the Extension Hub in SPSS Statistics 24. Try it on your own datasets to see if Benford’s Law holds true for your variables.

BONUS: Feel free to expand upon this extension by adding to the code. Simply open the Custom Dialog Builder for Extensions and click on the “Open Installed” button to view and modify the SPSS syntax used for this extension.