Is there a Pair-Wise PostHoc Comparisons for the Chi-Square Test in R?

Tal Galili picture Tal Galili · Mar 17, 2010 · Viewed 10k times · Source

I am wondering if there exists in R a package/function to perform the: "Post Hoc Pair-Wise Comparisons for the Chi-Square Test of Homogeneity of Proportions" (or an equivalent of it) Which is described here: http://epm.sagepub.com/cgi/content/abstract/53/4/951

My situation is of just making a chi test, on a 2 by X matrix. I found a difference, but I want to know which of the columns is "responsible" for the difference.

Thanks, Tal

Answer

IRTFM picture IRTFM · Mar 20, 2010

The "chi-square test" is usually generated as the sum of squared individual cell deviations from the "expected" = products of row and column sums divided by the total sum. As such, one can compare the individual cell contributions to the sum to the critical value of a chi-square with 1 d.f. It is a fairly simple task to modify the chisq.test() code to return the cell chi-squares. I just added:

cell.chisq = (x - E)^2/E,

to the structure call at the end. They won't get print()-ed, but you can assign the result to an object and use:

 obj$cell.chisq