[R] a statistic question about chisq.test()

Wiener, Matthew matthew_wiener at merck.com
Thu Mar 27 02:07:38 CET 2003


One other option.

I usually find that when I do the chisq.test with exact p-value calculation,
I find the p-values are nearly identical to the results when I use the
approximation and get the warnings (I'm usually dealing with just a few bins
with less than 5, and many bins with more than 5).

So frequently, when I'm using chisq.test in a program, and expect to do it
many times, I'll sometimes eliminate the warnings this way:

old.warn <- options()$warn
options(warn = -1)
< do the chisq.test here >
options(warn = old.warn)

This will suppress the warning messages.  

Hope this helps.

Matt Wiener

-----Original Message-----
From: Uwe Ligges [mailto:ligges at statistik.uni-dortmund.de] 
Sent: Wednesday, March 26, 2003 4:24 PM
To: aprilsun
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] a statistic question about chisq.test()


aprilsun wrote:
> 
> Hi,
> In the chisq.test(), if the expected frequency for some categories is <5,
there will be a warning message which says
> Warning message:
> Chi-squared approximation may be incorrect in: chisq.test(x, p = probs)

It's a warning message, not an error. It point's you to the problem that
a number < 5 is not "large", whereas in theory "large" numbers are
assumed when running this test.

 
> I am wondering whether there are some methods to get rid of this
mistake... Seems the ?chisq.test() doesn't provide more
> options to solve this problem. Or, the only choice is to preprocess the
data to avoid this situation?

It depends on the problem. Fisher's exact test (or it's extended
version) might be an alternative, see ?fisher.test and an appropriate
statistics textbook.

Uwe Ligges


> Thanks a lot!
> 
> aprilsun

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


------------------------------------------------------------------------------



More information about the R-help mailing list