collapseCategoricalCells function

Collapse small sample size categorical frequency counts

Collapse small sample size categorical frequency counts

collapseCategoricalCells(observed, expected, minExpected = 1)

Arguments

  • observed: the observed frequency table

  • expected: the expected frequency table

  • minExpected: the minimum expected cell frequency

    Pearson's X^2 test requires some minimum frequency per cell to avoid an inflated false positive rate. This function will merge cells with the lowest frequency counts until all the counts are above the minimum threshold. Cells that have been merged are filled with NAs. The resulting tables and number of merged cells is returned.

Examples

O = matrix(c(7,31,42,20,0), 1,5) E = matrix(c(3,39,50,8,0), 1,5) collapseCategoricalCells(O,E,9)