Learn R Programming

rpf (version 1.0.14)

collapseCategoricalCells: Collapse small sample size categorical frequency counts

Description

Collapse small sample size categorical frequency counts

Usage

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

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

Run the code above in your browser using DataLab