LR.mat.mult: Likelihood ratio test: Benford vs. General Multinomial

Description Usage Arguments Details Value References Examples

Description

LR.mat.mult is a likelihood ratio test for whether the first significant digits of a set of samples are compatible with Benford's Law, where H_0: cell probabilities follow Benford's, vs. H_1: the most general multinomial, i.e. all probabilities non-negative, sum to 1.

Usage

1
LR.mat.mult(freq, digits = 1:9)

Arguments

freq

Vector or matrix with multinomial samples in the rows.

digits

A significant digits vector. If unspecified, default is 1:9. digits must match the frequencies in the rows of freq.

Details

The LR statistic λ for testing H_0 vs. H_1 is:

-2logλ = -2 ∑ f_i{log(p_i) - log(f_i/n)}

where f_i is the frequency of the ith first digit, and p_i is the cell probability of the ith first digit.

Value

The output is a vector of p-values, one per sample (row).

References

Lesperance M, Reed WJ, Stephens MA, Tsao C, Wilton B (2016) Assessing conformance with Benford's Law: goodness-of-fit tests and simultaneous confidence intervals. PLoS one; 11(3). Wong, S. (2010) Testing Benford's Law with the first two significant digits. University of Victoria, Master's thesis.

Examples

1
2
3
LR.mat.mult(firstdigitsfreq(c(0.41, 1.25, 0.21, 0.54, 0.19), 1))
set.seed(123)
LR.mat.mult(firstdigitsfreq(rnorm(100), 1))

mlespera/BenGood documentation built on May 18, 2019, 3:43 p.m.