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) 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? Thanks a lot! aprilsun [[alternate HTML version deleted]]
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
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 thismistake... Seems the ?chisq.test() doesn't provide more> options to solve this problem. Or, the only choice is to preprocess thedata 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 ------------------------------------------------------------------------------
kjetil brinchmann halvorsen
2003-Mar-27 02:47 UTC
[R] a statistic question about chisq.test()
On 26 Mar 2003 at 13:35, aprilsun wrote: First, look at the expected values under the null. If only a few are below 5 and all are above 1 there are probably no problem. Second, you can use chisq.test with the argument simulate.p.value=TRUE Kjetil Halvorsen> 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) > > 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? > > Thanks a lot! > > aprilsun > > [[alternate HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help