BenfordTests-package {BenfordTests} | R Documentation |
Statistical Tests for Benford's Law
Description
This package contains several specialized statistical tests and support functions for determining if numerical data could conform to Benford's law.
Details
Package: | BenfordTests |
Type: | Package |
Version: | 1.2.0 |
Date: | 2015-07-18 |
License: | GPL-3 |
BenfordTests
is the implementation of eight goodness-of-fit (GOF) tests to assess if data conforms to Benford's law.
Tests include:
Pearson \chi^2
statistic (Pearson, 1900)
Kolmogorov-Smirnov D statistic (Kolmogorov, 1933)
Freedman's modification of Watson's U^2
statistic (Freedman, 1981; Watson, 1961)
Chebyshev distance m statistic (Leemis, 2000)
Euclidean distance d statistic (Cho and Gaines, 2007)
Judge-Schechter mean deviation a^*
statistic (Judge and Schechter, 2009)
Joenssen's J_P^2
statistic, a Shapiro-Francia type correlation test (Shapiro and Francia, 1972)
Joint Digit Test T^2
statistic, a Hotelling type test (Hotelling, 1931)
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^2
, D, a^*
, and T^2
statistics may also be determined using their asymptotic distributions.
Author(s)
Dieter William Joenssen
Maintainer: Dieter William Joenssen <Dieter.Joenssen@googlemail.com>
References
Benford, F. (1938) The Law of Anomalous Numbers. Proceedings of the American Philosophical Society. 78, 551–572.
Cho, W.K.T. and Gaines, B.J. (2007) Breaking the (Benford) Law: Statistical Fraud Detection in Campaign Finance. The American Statistician. 61, 218–223.
Freedman, L.S. (1981) Watson's Un2 Statistic for a Discrete Distribution. Biometrika. 68, 708–711.
Joenssen, D.W. (2013) Two Digit Testing for Benford's Law. Proceedings of the ISI World Statistics Congress, 59th Session in Hong Kong. [available under http://www.statistics.gov.hk/wsc/CPS021-P2-S.pdf]
Judge, G. and Schechter, L. (2009) Detecting Problems in Survey Data using Benford's Law. Journal of Human Resources. 44, 1–24.
Kolmogorov, A.N. (1933) Sulla determinazione empirica di una legge di distibuzione. Giornale dell'Istituto Italiano degli Attuari. 4, 83–91.
Leemis, L.M., Schmeiser, B.W. and Evans, D.L. (2000) Survival Distributions Satisfying Benford's law. The American Statistician. 54, 236–241.
Newcomb, S. (1881) Note on the Frequency of Use of the Different Digits in Natural Numbers. American Journal of Mathematics. 4, 39–40.
Pearson, K. (1900) On the Criterion that a Given System of Deviations from the Probable in the Case of a Correlated System of Variables is Such that it can be Reasonably Supposed to have Arisen from Random Sampling. Philosophical Magazine Series 5. 50, 157–175.
Shapiro, S.S. and Francia, R.S. (1972) An Approximate Analysis of Variance Test for Normality. Journal of the American Statistical Association. 67, 215–216.
Watson, G.S. (1961) Goodness-of-Fit Tests on a Circle. Biometrika. 48, 109–114.
Hotelling, H. (1931). The generalization of Student's ratio. Annals of Mathematical Statistics. 2, 360–378.
Examples
#Set the random seed to an arbitrary number
set.seed(421)
#Create a sample satisfying Benford's law
X<-rbenf(n=20)
#Look at sample
X
#Look at the first digits of the sample
signifd(X)
#Perform a Chi-squared Test on the sample's first digits using defaults
chisq.benftest(X)
#p-value = 0.648