distr.test | R Documentation |
This function extracts and performs a test of the distribution of (leading) digits in a vector against a reference distribution. By default, the distribution of leading digits is checked against Benford's law.
distr.test(x, check = 'first', reference = 'benford')
x |
a numeric vector. |
check |
location of the digits to analyze. Can be |
reference |
which character string given the reference distribution for the digits, or a vector of probabilities for each digit. Can be |
Benford's law is defined as p(d) = log10(1/d). The uniform distribution is defined as p(d) = 1/d.
An object of class dt.distr
containing:
observed |
the observed counts. |
expected |
the expected counts under the null hypothesis. |
n |
the number of observations in |
statistic |
the value the chi-squared test statistic. |
parameter |
the degrees of freedom of the approximate chi-squared distribution of the test statistic. |
p.value |
the p-value for the test. |
check |
checked digits. |
digits |
vector of digits. |
reference |
reference distribution |
data.name |
a character string giving the name(s) of the data. |
Koen Derks, k.derks@nyenrode.nl
Benford, F. (1938). The law of anomalous numbers. In Proceedings of the American Philosophical Society, 551-572.
distr.btest
rv.test
set.seed(1) x <- rnorm(100) # Digit analysis against Benford's law distr.test(x, check = 'first', reference = 'benford') # Digit analysis against custom distribution distr.test(x, check = 'last', reference = rep(1/9, 9))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.