Ben-Util: Beyond Benford Analysis
- Ben-Util is an R package that compares real-world digit distributions using Newcomb–Benford’s Law and the BDS model with upper-bound constraints.
- It employs chi-square goodness-of-fit tests to objectively assess which digit distribution model best matches the observed data.
- The package provides user-friendly functions for digit extraction, theoretical probability computation, and visual comparison to support model selection.
Ben-Util (BeyondBenford) is an R package designed to compare the empirical digit distributions of real-world datasets with two theoretical models: Newcomb–Benford’s Law and the Blondeau Da Silva (BDS) model. Its primary utility is for researchers and practitioners evaluating whether observed digit frequencies—particularly leading or p-th digits—are better explained by the widely cited logarithmic Benford distribution or the parameterized, data-bound BDS model (Silva, 2019).
1. Decision Problem: Modeling Digit Distributions
Empirical investigations consistently demonstrate that leading digits in many natural datasets are not uniformly distributed, instead often exhibiting a logarithmic decay described by Newcomb–Benford’s Law. The BDS model extends this, formalizing how an upper-bound constraint on the data induces fluctuations around Benford frequencies. Ben-Util operationalizes this comparative inquiry by offering a workflow to assess, for any dataset of positive real numbers, whether the Benford or BDS distribution more appropriately models its observed digits, using goodness-of-fit metrics (Silva, 2019).
2. Explicit Theoretical Formulations
Let be the digit of interest (first digit ; in general, the th digit ).
Newcomb–Benford’s Law:
Blondeau Da Silva’s (BDS) Model:
If the integer upper bound for the data is and focusing on the th digit,
For first digit :
These formulas codify the two candidate distributions underlying Ben-Util comparisons. The Benford model is parameter-free; the BDS model depends explicitly on 0 matched to the dataset’s observed maximum (Silva, 2019).
3. Core Functionality and Workflow
Ben-Util (BeyondBenford) provides a suite of R functions facilitating full digit-distribution analysis:
- obs.numb.dig(dat, dig): Extracts observed frequencies for each digit (positions 0–9) at digit position
digfrom a vector or data-framedat. - Benf.val(fig, dig): Computes Benford’s theoretical probability for digit
figat positiondig. - Blon.val(fig, dig, upbound): Computes BDS’s probability for digit
figat positiondig, with parameterupbound. - dat.distr(dat, dig=1, upbound=ceiling(max(dat)), ...): Plots histograms of observed digit frequencies, optionally overlaying theoretical curves and providing 1 summaries.
- Key arguments:
nclass: Number of bins,theor: Whether to plot the BDS curve,nchi: If 2, merges bins for robust 3.
- digit.distr(dat, dig, upbound, mod="ben"|"BDS"|"benblo", ...): Plots comparisons between the observed, Benford, and/or BDS digit distributions.
- chi2(dat, dig, upbound=…, mod="ben"|"BDS", pval=0|1): Computes Pearson’s 4 and optionally 5-value for goodness-of-fit to the chosen model (Silva, 2019).
This workflow enables detailed side-by-side quantitative and graphical comparisons between candidate distributions.
4. Observed Versus Expected Frequencies
Frequencies are computed as follows:
- Observed counts:
6
For first digit analyses, focus on 7.
- Expected counts:
- Benford:
8 - BDS:
9
with 0 indicating records with at least dig digits (Silva, 2019).
These serve as empirical-theoretical pairs input to the 1 test.
5. Statistical Testing: Pearson’s 2 Test
For bins 3 (typically digits 1–9 or 0–9):
4
Under the null hypothesis (5), 6 with 7 if no parameters are estimated from the data. The 8-value is
9
In Ben-Util, bins are merged if necessary to ensure all expected frequencies 0, following the standard Pearson’s rule. This procedure provides a statistical measure of the adequacy of each model’s fit (Silva, 2019).
6. Example Analysis Pipeline
The illustrative R workflow using Ben-Util includes:
5
Reported outputs for this example indicate strong fits for both models:
- Benford 1, 2
- BDS 3, 4 The lower 5 and higher 6 indicate BDS provides a marginally better fit (Silva, 2019).
7. Model Selection and Interpretation
Assessment proceeds by juxtaposing 7 statistics and 8-values. The preferred model is the one yielding the smaller 9 and larger 0-value:
- If both 1, either model may be considered plausible.
- If only one model yields 2, preference should be given to that model.
- For closely matching 3-values, differences in the 4 statistic may provide additional guidance (Silva, 2019).
A plausible implication is that, in datasets subject to explicit upper bounds or selection effects, BDS should be favored over Benford when it offers a superior empirical fit. However, with both models highly plausible, interpretative caution and context-specific considerations remain essential.
This framework enables rigorous, reproducible comparison of empirical digit distributions in diverse disciplines, using the operational tools provided by the Ben-Util (BeyondBenford) package (Silva, 2019).