4

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

APC
  • 144,005
  • 19
  • 170
  • 281
Tal Galili
  • 24,605
  • 44
  • 129
  • 187
  • 1
    Tal, I have a feeling that this is off-topic here. You know where to find r-help as you have been cross-posting for the last few days anyway. – Dirk Eddelbuettel Mar 17 '10 at 18:09
  • Hi Dirk, I appreciate your suggestion and suspect that your feeling will turnout correct. The reason I posted it here is because I already asked this question on the R-help a few months ago and got no answer. So I thought to check if someone here might have came across a solution. Best, Tal – Tal Galili Mar 17 '10 at 19:01
  • Hi Shane it seems both you and Dirk are correct. Also, I didn't know about mathoverflow - thanks for the link! – Tal Galili Mar 17 '10 at 19:27
  • @Tal: perhaps you can improve this question now that you have your advanced degree in statisics? I see that the cited article has been criticized as not statistically correct: https://www.semanticscholar.org/paper/Pairwise-Comparisons-for-Proportions%3A-A-Note-on-Cox-Seaman-Hill/22b65dc3b78cf7f1e858d386628221cc3ed1562f (That's not an uncommon occurence when the topic is multiple comparisons.) – IRTFM Mar 08 '21 at 19:29

3 Answers3

3

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
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • 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 Mar 21 '10 at 12:19
  • 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. – IRTFM Apr 04 '10 at 15:26
1

See the fifer package for function chisq.post.hoc()

0

Not sure if it works for your problem but I read an article which uses the following to perform pairwise chi-sqr test

rcompanion::pairwiseNominalIndependence()
Tianyi
  • 1