chisq.comb: Combine categories for a chi-square goodness of fit test

View source: R/ChisqComb.R

chisq.combR Documentation

Combine categories for a chi-square goodness of fit test

Description

This function combines categories for a chi-square goodness of fit test.

Usage

chisq.comb(chisq.test, combine)

Arguments

chisq.test

The output of a chi-square goodness of fit test by functions chisq.bin or chisq.Pois.

combine

A vector with the numbers of the categories to combine.

Details

This function only cobines categories on the extremes. It is recommended to combine categories when the expected counts are too low. As a rule of thumb, the chi-square approximation for the test statistic can be unreliable if some categories have expected counts smaller than 5 or if there is any with an expected count smaller than 1.

Value

It returns a table with the contribution to the chi-square statistic for each category, the chi-square statistic, the degrees of freedom, and the p-value.

Author(s)

Raúl Eyzaguirre.

Examples

x <- 0:6
f <- c(334, 369, 191, 63, 22, 12, 9)
output <- chisq.bin(x, f, n = 10)
# Combine categories 5, 6, and 7
chisq.comb(output, combine = c(5, 6, 7))

reyzaguirre/rhep documentation built on Dec. 2, 2024, 4:22 p.m.