td_independence {terminaldigits} | R Documentation |
Test of independence of terminal digits
Description
The td_independence
function tests the independence of terminal digits from
preceding digits by constructing a contingency table of counts where rows constitute
unique preceding digits and columns constitute unique terminal digits. A test of
independence for a contingency tables is then implemented via Monte Carlo
simulation.
Usage
td_independence(
x,
decimals,
reps = 10000,
test = "Chisq",
tolerance = 64 * .Machine$double.eps
)
Arguments
x |
a numeric vector |
decimals |
an integer specifying the number of decimals. This can be zero if the terminal digit is not a decimal. |
reps |
a positive integer specifying the number of Monte Carlo simulations. The default is set to 10,000 which may be appropriate for exploratory analysis. A higher number of simulation should be selected for more precise results. |
test |
a string specifying the test of independence. The default is Pearson's chi-squared statistic ("Chisq"). Also available is the log-likelihood ratio statistic ("G2"), the Freeman-Tukey statistic ("FT"), and the Root-mean-square statistic ("RMS"). |
tolerance |
sets an upper bound for rounding errors when evaluating
whether a statistic for a simulation is greater than or equal to the
statistic for the observed data. The default is identical to the tolerance
set for simulations in the |
Details
Monte Carlo simulations are implemented for contingency tables with fixed margins using algorithm ASA 144 (Agresti, Wackerly, and Boyett, 1979; Boyett 1979).
Value
A list with class "htest" containing the following components:
statistic |
the value of the test statistic |
p_value |
the simulated p-value for the test |
method |
a character string describing the test |
data.name |
a character string give the name of the data |
References
Agresti, A., Wackerly, D., & Boyett, J. M. (1979). Exact conditional tests for cross-classifications: approximation of attained significance levels. Psychometrika, 44(1), 75-83.
Boyett, J. M. (1979). Algorithm AS 144: Random r × c tables with given row and column totals. Journal of the Royal Statistical Society. Series C (Applied Statistics), 28(3), 329-332.
Examples
td_independence(decoy$weight, decimals = 2, reps = 2000)