Re: [R] In chisq.test(x) : Chi-squared approximation may be incorrect

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Wed, 16 Jan 2008 04:33:09 +0000 (UTC)

"My Coyne" <mcoyne_at_boninc.com> wrote in
news:000e01c8573a$ad60c8a0$082259e0$@com:

> I received the following warning when running chi-square;
>
> n Is there a way to catch the 'error' code of 'warning' after run
> chisq.test(x)?

It is not an error message. It is a warning message. When I assign the result of chisq.test(.) to an object and then look at its structure with str(), I do not see the warning message "in there". Instead the message appears on the console. When you look at the chisq.test function itself you see that any "E" less than 5 will trigger the warning:

if (any(E < 5) && is.finite(PARAMETER))

        warning("Chi-squared approximation may be incorrect")

You should be able to check the <object>$expected matrix in a similar manner if you goal is to process a large number of tables programatically.

>
> n What does this error mean?

See above. Consider invoking chisq.test with the simulate.p.value option.

-- 
David Winsemius

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 16 Jan 2008 - 04:39:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Jan 2008 - 07:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive