0

In base R, the function chisq.test() "performs chi-squared contingency table tests and goodness-of-fit tests".

However, chisq.test() only takes a numeric vector or matrix, and not a three-way (three-dimensional) contingency table.

Is there a similar function for a three-way contingency table (i.e., array) in R?

Joshua Rosenberg
  • 754
  • 10
  • 26
  • 1
    I think you will find the information you need in the linked thread. Please read it. If it isn't what you want / you still have a question afterwards, come back here & edit your question to state what you learned & what you still need to know. Then we can provide the information you need without just duplicating material elsewhere that already didn't help you. – gung - Reinstate Monica Dec 07 '16 at 18:58
  • Thanks @gung, one question -is the second (not your accepted) answer to the question (that basically says "a three dimensional contingency table is actually pretty much analogue to the standard variant" on the wrong track? – Joshua Rosenberg Dec 07 '16 at 19:05
  • I would not use that method, @Joshua. If you have a 3-d table, & you only want to know if rows are independent of columns, & don't care about pages, you could use the [Cochran Mantel Haenszel test](https://en.wikipedia.org/wiki/Cochran%E2%80%93Mantel%E2%80%93Haenszel_statistics) (in `R`, [?mantelhaen.test](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/mantelhaen.test.html)). – gung - Reinstate Monica Dec 07 '16 at 19:13
  • This likely reflects a misunderstanding about Chi-square tests of proportion, but I'm interested in evaluating the standardized residuals to determine whether a specific cell is more or less likely than would be expected. I'm specifically interested in whether a cell for a specific row, column, and page is greater (or lesser) than expected. – Joshua Rosenberg Dec 07 '16 at 19:18
  • 1
    I wonder if I'm missing your point, but that sounds fine. I would probably use a log linear model for that. – gung - Reinstate Monica Dec 07 '16 at 19:45
  • Using your example and `MASS::loglm()` I made my data into an `array` and used the model formula `row_name + column_name + page_name` (with the actual row, column, and page names), the evaluated the standardized residuals to determine whether a specific cell is more or less likely than expected. Given limited info., does this sound like reasonable way to go? – Joshua Rosenberg Dec 07 '16 at 21:02
  • It's hard to say. Do you wonder about all 3 variables, or do you only care about r x c, w/ p as a nuisance variable? – gung - Reinstate Monica Dec 07 '16 at 21:15
  • In this case, I care about all 3 - each are substantively important and I am viewing them as independent of each other – Joshua Rosenberg Dec 07 '16 at 21:18
  • That seems fine, then. – gung - Reinstate Monica Dec 07 '16 at 21:59
  • This has been working well for my analysis. However, I am unsure whether it is possible to calculate an effect size like Cramer's V for a chi-square test. Can you suggest how to calculate the effect size? – Joshua Rosenberg Dec 17 '16 at 18:41
  • 1
    That's a viable new question. But you would need to specify what you want the effect size to measure. – gung - Reinstate Monica Dec 17 '16 at 21:00
  • I did my best to ask this here http://stats.stackexchange.com/questions/252141/effect-size-for-correlation-of-variables – Joshua Rosenberg Dec 17 '16 at 21:24

0 Answers0