I am looking for a currently-working method of running a chi-square post hoc test.

I've run a chi-square test of homogeneity using chisq.test from stats, however, I am at a loss when it comes to suitable post hoc tools. People recommend FIFER package, however, how do I make it suitable for a homogeneity test?

Can someone please point me in the right direction. I am fairly new to chi squares and R, so apologies if I'm missing something obvious.

My data is contracted as 3 groups (rows) x 5 categories (columns).

  • $\begingroup$ sorry, yes, Edited question $\endgroup$
    – Green
    Commented Oct 7, 2019 at 9:56
  • $\begingroup$ stats, lower case. Case matters in this .... er, case. MASS is all caps (since it's an acronym) but most names of packages distributed with R are all small letters. $\endgroup$
    – Glen_b
    Commented Oct 7, 2019 at 9:58

1 Answer 1


As stated here, you can modify the chisq.testto compute partial X2 statistics for rows or columns. Then you can get the corrected p-values with p.adjust for bonferroni or other corrections.

nr <- as.integer(nrow(x))
nc <- as.integer(ncol(x))
sr <- rowSums(x)
sc <- colSums(x)
E <- outer(sr, sc, "*")/n
dimnames(E) <- dimnames(x)

STATISTIC <- sum((abs(x - E) )^2/E)
PARAMETER <- (nr - 1L) * (nc - 1L)
PVAL <- pchisq(STATISTIC, PARAMETER, lower.tail = FALSE)
cat("X-squared =",PARAMETER,", df=",PARAMETER, ", p-value =",PVAL)
(cell.chisq = (x - E)^2/E)

p=pchisq(rowSums(cell.chisq), df =  1,lower.tail = FALSE)

round(p.adjust(p), 3)
round(p.adjust(p, "bonferroni"), 3)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.