BeyondBenford (version 1.0)

chi2: Pearson's chi-squared test

Description

It is a test of goodness of fit to find out whether the distribution of first (second, third or fourth) digit in the studied data differs from two theoretical distributions (that of Benford and that of Blondeau Da Silva) or not. The null hypothesis states that the studied distribution is consistent with the considered theoretical distribution.

Usage

chi2(dat, mod = "ben", upbound = ceiling(max(dat)), dig = 1, pval = 0)

Arguments

dat

The considered dataset, a data frame containing non-zero real numbers.

mod

If mod="ben", the theorical distribution considered is that of Benford, else it is Blondeau Da Silva's ones which is chosen.

upbound

A positive integer, which characterizes the data. All (or most) of the data are lower than this "upper bound".

dig

The chosen position of the digit (from the left).

pval

If pval=0, the p-value is not returned, else it is available.

Value

A data frame containing the Pearson chi-squared statistic (and the associated p-value if requested).

References

K. Pearson (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, 50(302):157-175.

Examples

Run this code
# NOT RUN {
data(address_PierreBuffiere)
chi2(address_PierreBuffiere,dig=2,pval=1)
chi2(address_PierreBuffiere,dig=2,pval=1,mod="blo")

# }

Run the code above in your browser using DataCamp Workspace