In some instances, chisq.test()
will return a warning such as that shown below.
> ( chi1 <- chisq.test(freq) )
Warning in chisq.test(freq): Chi-squared approximation may be incorrect
Chi-squared test for given probabilities with freq
X-squared = 6.8947, df = 3, p-value = 0.07533
This warning occurs when one or more expected values is less than five. This is confirmed by viewing the expected table.
> chi1$expected
[1] 4.75 4.75 4.75 4.75
In this example, each cell in the expected table is less than five (note that this example is for a goodness-of-fit test but the concept is the same for a two-variable chi-square test).
This problem may be corrected in two ways. First, you may collect a larger sample size. Second, some categories may be combined to reduce the number of cells in the table and, thus, increase the expected values.