jpsq.benftest {BenfordTests}R Documentation

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

Description

jpsq.benftest 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

jpsq.benftest(x = NULL, digits = 1, pvalmethod = "simulate", pvalsims = 10000)

Arguments

x

A numeric vector.

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.

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".

Details

A statistical test is performed utilizing the sign-preserved squared correlation between
signifd(x,digits) and pbenf(digits). Specifically:

J_P^2=sgn\left(cor\left(f^o, f^e\right)\right)\cdot cor\left(f^o, f^e\right) ^2

where f^o denotes the observed frequencies and f^e denotes the expected frequency of digits
10^{k-1},10^{k-1}+1,\ldots,10^k-1. x is a numeric vector of arbitrary length. Values of x should be continuous, as dictated by theory, but may also be integers. digits should be chosen so that signifd(x,digits) is not influenced by previous rounding.

Value

A list with class "htest" containing the following components:

statistic

the value of the J_P^2 test statistic

p.value

the p-value for the test

method

a character string indicating the type of test performed

data.name

a character string giving the name of the data

Author(s)

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.

Joenssen, D.W. (2013) A New Test for Benford's Distribution. In: Abstract-Proceedings of the 3rd Joint Statistical Meeting DAGStat, March 18-22, 2013; Freiburg, Germany.

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]

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.

See Also

pbenf, simulateH0

Examples

#Set the random seed to an arbitrary number
set.seed(421)
#Create a sample satisfying Benford's law
X<-rbenf(n=20)
#Perform Joenssen's \emph{JP-square} Test
#on the sample's first digits using defaults
jpsq.benftest(X)
#p-value = 0.3241

[Package BenfordTests version 1.2.0 Index]