digit_pairs_test: Performs terminal digit pair binomial test vs uniform...

View source: R/digit_pair_test.R

digit_pairs_testR Documentation

Performs terminal digit pair binomial test vs uniform distribution (Benford’s Law)

Description

Performs terminal digit pair binomial test vs uniform distribution (Benford’s Law)

Usage

digit_pairs_test(
  digitdata,
  data_columns = "all",
  omit_05 = NA,
  min_length = 3,
  break_out = NA,
  test_alternative = "less",
  break_out_grouping = NA,
  plot = TRUE
)

Arguments

digitdata

A object of class DigitAnalysis.

data_columns

The names of numeric columns of data to be analyzed. Default can be 'all', where using all data columns in numbers df in digitdata; an array of column names, as characters; a single column name, as character.

omit_05

Whether to omit 0 or both 0 and 5. If omit both 0 and 5, pass in c(0,5) or c(5,0); if omit only 0 pass in 0 or c(0); if omit neither, pass in NA. Default to NA.

min_length

The minimum length of the numbers to be analyzed in digit pair test. Must be an integer >= 2. Default to 3.

break_out
  • The data column (non-numeric!) to split up the dataset based on different categories in the column if specified as an character.

  • The first division (usually x-axis) shown in plots.

  • Default to NA.

test_alternative

The test alternative for binomial test performed.

  • 'l' or 'less': The default; test against the alternative: less than the expected frequency

  • 't' or 'two.sided': Test against the alternative: more or less than the expected frequency

break_out_grouping

A list of arrays, or defaulted to NA. Only effective if break_out is not NA.

  • Each the names of the elements in the list is the break_out name

  • Each array contains the values belonging to that break_out

  • If it is remain as NA as default, while break_out is not NA, then break_out_grouping will default to every individual item in break_out will be in a separate group.

plot

TRUE or FALSE or 'Save': If TRUE, display the plots and return them. If 'Save', return the plots but suppress display. If FALSE, no plot is produced. Default to TRUE.

Value

  • A table of p-values for terminal digit pair test on each category

  • A table of sample sizes for terminal digit pair test on each category

  • Plots for each category if plot = TRUE or 'Save'

Examples

digit_pairs_test(digitdata, data_columns='all')
digit_pairs_test(digitdata, data_columns=c('col_name1', 'col_name2'))
digit_pairs_test(digitdata, data_columns='all', omit_05=NA, min_length=5)
digit_pairs_test(digitdata, data_columns='all', omit_05=0, break_out='col_name')

jlederluis/digitanalysis documentation built on Nov. 5, 2023, 11:46 a.m.