jointdigit.benftest {BenfordTests}R Documentation

A Hotelling T-square Type Test for Benford's Law

Description

jointdigit.benftest takes any numerical vector reduces the sample to the specified number of significant digits and performs a Hotelling T-square type goodness-of-fit test to assert if the data conforms to Benford's law.

Usage

jointdigit.benftest(x = NULL, digits = 1, eigenvalues="all", tol = 1e-15, 
					pvalmethod = "asymptotic", 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.

eigenvalues

How are the eigenvalues, which are used in testing, selected.

tol

Tolerance in detecting values that are essentially zero.

pvalmethod

Method used for calculating the p-value. Currently only "asymptotic" is available.

pvalsims

An integer specifying the number of replicates used if pvalmethod = "simulate".

Details

A Hotelling T^2 type goodness-of-fit test is performed on signifd(x,digits) versus pbenf(digits). x is a numeric vector of arbitrary length. argument: eigenvalues can be defined as:

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 T^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

eigenvalues_tested

a vector containing the index numbers of the eigenvalues used in testing.

eigen_val_vect

the eigen values and vectors of the null distribution. computed using eigen.

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.

Hotelling, H. (1931). The generalization of Student's ratio. Annals of Mathematical Statistics. 2, 360–378.

See Also

pbenf

Examples

#Set the random seed to an arbitrary number
set.seed(421)
#Create a sample satisfying Benford's law
X<-rbenf(n=20)
#Perform  Test
#on the sample's first digits using defaults
jointdigit.benftest(X)
#p-value = 0.648
#Perform  Test
#using only the two largest eigenvalues
jointdigit.benftest(x=X,eigenvalues=1:2)
#p-value = 0.5176
#Perform  Test
#using the kaiser selection criterion
jointdigit.benftest(x=X,eigenvalues="kaiser")
#p-value = 0.682

[Package BenfordTests version 1.2.0 Index]