# How to compare two Crosstabs for significance?

I have two crosstabs and need to determine whether their differences are significant. Both tables have the same independent variable but different populations. E.g.,

The only test I know to do is to convert these two 2x3 tables into 1x6 tables and then perform a 2x6 chi square. Is this a reasonable way to proceed?

EDIT: Changed the titles of the columns

• Why would they be the same? it seems to be comparing apples with oranges and expecting them to be the same color. By what mechanism could the null be remotely plausible? – Glen_b Nov 14 '18 at 0:24
• @Glen_b I changed the title of my sample data to be apples-to-apples. Do you have an answer now? – buttonsrtoys Nov 14 '18 at 18:25
• Look up the Cochran Mantel Hanzel Test. Alternatively, you should do a Poisson like regression. – Demetri Pananos Nov 14 '18 at 18:49
• What is the hypothesis about the populations? Can you tell me more about the problem you are tackling? – Demetri Pananos Nov 14 '18 at 19:06
• @buttonsrtoys changing the name you attach to an orange doesn't make it an apple, and what matters is what they are not what they're labelled. What is it that this test is supposed to tell you about the population? (Perhaps Demetri puts it better -- what is the hypothesis about the population?) – Glen_b Nov 14 '18 at 22:58

This looks like a stratified contingency table. I'm assuming here that Meds is an ordinal variable and that the column names are the outcome (e.g. Died or Lived).

You haven't told us what difference you want to evaluate. Between population differences? Between medication type differences? Depending on the complexity of the hypothesis you are evaluating, you can perform a logistic regression. Here is some sample R code:

library(tidyverse)

#Population 1
x = as.table(matrix(c(42,58,44,59,50,47), nrow = 3))
rownames(x) = c(0,1,2)
colnames(x) = c(0,1)
dimnames(x) = list(Meds = c(0,1,2) ,Outcome = c(0,1))

x = as.data.frame.table(x) %>% mutate(Population = 1)

#Population 2
y = as.table(matrix(c(40,64,52,61,44,39), nrow = 3))
rownames(y) = c(0,1,2)
colnames(y) = c(0,1)
dimnames(y) = list(Meds = c(0,1,2) ,Outcome = c(0,1))

y = as.data.frame.table(y) %>% mutate(Population = 2)

data = x %>%
bind_rows(y) %>%
as.tibble() %>%
mutate(Population = factor(Population))

mod = glm(Outcome ~ Meds + Population, data = data, family = binomial(), weights = Freq)

summary(mod)


The variables in the model explain some of the variability observed in the data (this is evaluated by a deviance goodness of fit test), but a lot of residual variability remains. Again, the appropriateness of this approach depends on what hypothesis you are evaluating