views:

372

answers:

1

Hi all,

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

A: 

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
DWin
Thanks Dwin. Yet, my question had to do with comparing two rows (or columns) to find out which pairs are significant. One could try all the column pairwise tables and compute their P values - but how do you then correct for the multiplicity ?
Tal Galili
Sum the rows of obj$cell.chisq and apply the Bonferroni adjustment to p-values derived from the chisq critical values. The key point is that "chisq tests" on tables are decomposable by cell, by row, or by column or by combinations of these. People are misled by their intor stats course into thinking that "chi-square test" just means one thing, when in fact it means many things. The analyst still needs to keep clear in his head what is being tested and how many degrees of freedom his entire analysis has consumed.
DWin