small_test.Rd
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.
small_test(data, var, group)
A data frame containing the variables to be tested.
A character string specifying the factor variable in data
to test.
A character string specifying the grouping variable in data
.
A character string with one of three values:
"not_small"
: Sample size >=40 and all expected frequencies >=5
"small"
: Sample size >=40, all expected frequencies >=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
if (FALSE) {
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")
}