Learn R Programming

BenfordTests (version 0.5)

J_stat_squ_benford: Joenssen's JP-square Test for Benford's Law

Description

J_stat_squ_benford takes any numerical vector reduces the sample to the specified number of significant digits and performs a goodness-of-fit test based on the correlation between the first digits' distribution and Benford's distribution to assert if the data conforms to Benford's law.

Usage

J_stat_squ_benford(x = NULL, first_digits = 1, method = "pearson", pvalmethod = "simulate", pvalsims = 10000)

Arguments

x
A numeric vector.
first_digits
An integer determining the number of first digits to use for testing, i.e. 1 for only the first, 2 for the first two etc.
method
A character string indicating which correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman", can be abbreviated.
pvalmethod
Method used for calculating the p-value. Currently only "simulate" is available.
pvalsims
An integer specifying the number of replicates used if pvalmethod = "simulate".

Value

  • A list with class "code{htest}" containing the following components:
  • statisticthe value of the JP-square test statistic
  • p.valuethe p-value for the test
  • methoda character string indicating the type of test performed

Details

A statistical test is performed utilizing the sign-preserved squared correlation between leading_digits(x,first_digits) and pbenf(first_digits). x is a numeric vector of arbitrary length. Values of x should be continuous, as dictated by theory, but may also be integers. first_digits should be chosen so that leading_digits(x,first_digits) is not influenced by previous rounding.

References

Benford F. The law of anomalous numbers. Proceedings of the American Philosophical Society. 1938;78:551-572. Joenssen DW. A new test for Benford's distribution [abstract]. In: Abstract-proceedings of the 3rd joint Statistical Meeting DAGStat, March 18-22, 2013; Freiburg, Germany. Shapiro SS, Francia RS. An approximate analysis of variance test for normality. Journal of the American Statistical Association. 1972;67:215-216.

See Also

pbenf