# Chi-squared test for three-way contingency table (i.e., array) in R [duplicate]

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?

• 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 7 '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 7 '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 (in R, ?mantelhaen.test). – gung - Reinstate Monica Dec 7 '16 at 19:13
• 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 7 '16 at 19:45
• 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