small_test {tidysummary} | R Documentation |
Check Sample Size Adequacy for Chi-Squared Test
Description
This function determines if a contingency table meets the expected frequency assumptions for a valid chi-squared test. It categorizes the data into "not_small", "small", or "very_small" based on sample size and expected frequencies.
Usage
small_test(data, var, group)
Arguments
data |
A data frame containing the variables to be tested. |
var |
A character string specifying the factor variable in |
group |
A character string specifying the grouping variable in |
Value
A character string with one of three values:
-
"not_small"
: Sample size more than or euqal to 40 and all expected frequencies more than or euqal to 5 -
"small"
: Sample size more than or euqal to 40, all expected frequencies more than or euqal to 1 and at least one <5, only for 2*2 contingency tables -
"very_small"
: Other conditions, including sample size <40 or any expected frequency <1
Examples
df <- data.frame(
category = factor(c("A", "B", "A", "B")),
group = factor(c("X", "X", "Y", "Y"))
)
small_test(data = df, var = "category", group = "group")