[R] Problem applying Chi-square in R and Cochran's Recommendations

Johannes Huesing johannes at huesing.name
Wed Dec 29 16:22:02 CET 2010


Manoj Aravind <aravindbm at gmail.com> [Wed, Dec 29, 2010 at 03:59:16PM CET]:
> Sir,
> 
> I have a problem here while applying chisquare test to the following Data (
> below the subject of this mail) ...when I wanted to test the significance
> using three different free statistical packages, here R, EpiInfo and
> OpenEpi.
> 
> *Only OpenEpi accepts the test based on Cochran's Recommendations. *
> R says " chi squared approximation may be incorrect."
> Does it mean the same as what EpInfo saying " Chi square is not valid"

Yes. Take confidence from the fact that arithmetically all three
programs arrive at the same result (anything but surprising).
The recommendations when to trust Chi-Square are similar. R lets
you look at the source though, so if you type

> chisq.test

you get a result containing the following lines:

        sr <- rowSums(x)
        sc <- colSums(x)
        E <- outer(sr, sc, "*")/n

(so E contains the expected values for the cell entries)

and

	names(PARAMETER) <- "df"
    	if (any(E < 5) && is.finite(PARAMETER)) 
            warning("Chi-squared approximation may be incorrect")

so it seems that R is fussier about the quality of the approximation
than EpiInfo: 

[...]
> ------------------------------
>   Chi Square=43.81Degrees of Freedom=2p-value= <0.0000001 Cochran recommends
> accepting the chi square if: 1. No more than 20% of cells have expected < 5.2.
> No cell has an expected value < 1. In this table: 17% of 6 cells have
> expected values < 5.No cells have expected values < 1.  *Using these
> criteria, this chi square can be accepted.*  Expected value = row
> total*column total/grand total Rosner, B. Fundamentals of Biostatistics. 5th
> ed. Duxbury Thompson Learning. 2000; p. 395
> 

Note that these are recommendations which you are free to heed or ignore.

-- 
Johannes Hüsing               There is something fascinating about science. 
                              One gets such wholesale returns of conjecture 
mailto:johannes at huesing.name  from such a trifling investment of fact.                
http://derwisch.wikidot.com         (Mark Twain, "Life on the Mississippi")



More information about the R-help mailing list