BenfordTests
is the implementation of the seven most commonly used goodness-of-fit (GOF) tests to assess if data conforms to Benford's law.
Tests include:
Pearson chi-square statistic (Pearson (1900))
Kolmogorov-Smirnov D statistic (Kolmogorov (1933))
Freedman's modification of Watson's U-square statistic (Freedman (1981), Watson (1961))
Chebyshev distance m statistic (Leemis (2000))
Euclidean distance d statistic (Cho and Gaines (2007))
Judge-Schechter mean deviation a-star statistic (Judge and Schechter (2009))
Joenssen's JP-square statistic, a Shapiro-Francia type correlation test (Shapiro and Francia (1972))
All tests may be performed using more than one leading digit.
All tests simulate the specific p-values required for statistical inference, while p-values for the chi-square and D statistics may also be determined using their asymptotic distributions.
The package version numbers are indicative of performance and breadth of functions.#Create a sample satisfying Benford's law
X<-rbenf(n=20)
X
#Look at the first digits of the sample
leading_digits(X)
#Perform a Chi-squared Test on the sample's first digits
chi_square_benford(X)
Run the code above in your browser using DataLab