MyNixOS website logo
Description

Tests of Uniformity and Independence for Terminal Digits.

Implements simulated tests for the hypothesis that terminal digits are uniformly distributed (chi-squared goodness-of-fit) and the hypothesis that terminal digits are independent from preceding digits (several tests of independence for r x c contingency tables). Also, for a number of distributions, implements Monte Carlo simulations for type I errors and power for the test of independence.

terminaldigits

The package terminaldigits implements simulated tests of uniformity and independence for terminal digits. For certain parameters, terminaldigits also implements Monte Carlo simulations for type I errors and power for the test of independence. Simulations are run in C++ utilizing Rcpp.

Installation

You can install the development version of terminaldigits from GitHub with:

# install.packages("devtools")
devtools::install_github("josh-mc/terminaldigits")

Usage

In many cases, terminal digits can be assumed to be uniformly distributed and independent of preceding digits. A violation of either of these assumptions may point to a data quality issue.

The following examples are based on a data set taken from the third round of a decoy experiment involving hand-washing purportedly carried out in a number of factories in China. For details, see decoy and Yu, Nelson, and Simonsohn (2018).

The td_uniformity function tests the assumption of uniformity using Pearson’s chi-squared statistic for goodness-of-fit.

library(terminaldigits)

td_uniformity(decoy$weight, decimals = 2, reps = 1000)
#> 
#>  Pearson's chi-squared GOF test for uniformity of terminal digits
#> 
#> data:  decoy$weight
#> Chi-squared = 539.67, p-value = 0.000999

The td_independence function tests the assumption of independence. The default statistic is again Pearson’s chi-squared statistic but the log-likelihood ratio statistic, the Freeman-Tukey statistic, and the root-mean-square statistic are also available.

td_independence(decoy$weight, decimals = 2, reps = 1000)
#> 
#>  Chisq test for independence of terminal digits
#> 
#> data:  decoy$weight
#> Chisq = 6422.4, p-value = 0.000999

The td_test function is a wrapper for the above two functions. For more details, including a discussion of the td_simulate function, see the package introduction vignette.

References

Yu, F., Nelson, L., & Simonsohn, U. (2018, December 5). “In Press at Psychological Science: A New ‘Nudge’ Supported by Implausible Data.” DataColoda 74. http://datacolada.org/74

Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows