# What is the null model for a four-way contingency table?

I'm working through this tutorial on the Titanic data in R, a four-way contingency table, and I'm unclear as to what is the NULL model in this context?

> data(Titanic)
> ftable(Titanic)
Survived  No Yes
Class Sex    Age
1st   Male   Child            0   5
Adult          118  57
Female Child            0   1
Adult            4 140
2nd   Male   Child            0  11
Adult          154  14
Female Child            0  13
Adult           13  80
3rd   Male   Child           35  13
Adult          387  75
Female Child           17  14
Adult           89  76
Crew  Male   Child            0   0
Adult          670 192
Female Child            0   0
Adult            3  20


The following would be the model of (mutual) independence for the Titanic data:

> (x <- glm(Freq ~ Sex + Class + Age + Survived, poisson, data.frame(Titanic)))

Call:  glm(formula = Freq ~ Sex + Class + Age + Survived, family = poisson,
data = data.frame(Titanic))

Coefficients:
(Intercept)    SexFemale     Class2nd     Class3rd    ClassCrew     AgeAdult  SurvivedYes
2.1482      -1.3037      -0.1313       0.7758       1.0018       2.9545      -0.7399

Degrees of Freedom: 31 Total (i.e. Null);  25 Residual
Null Deviance:      4953
Residual Deviance: 1244     AIC: 1385
> sum(residuals(x, type = "pearson")^2)  ## Pearson's X^2 score test
 1637.445


This little is straightforward. I get confused though as to what is the difference between the "Null" model above with 31 df, and the mutual independence model with 25 df.

Compounding the confusion is that summary and chisq.test seem to be doing different things:

> summary(Titanic)
Number of cases in table: 2201
Number of factors: 4
Test for independence of all factors:
Chisq = 1637.4, df = 25, p-value = 0
Chi-squared approximation may be incorrect
> chisq.test(Titanic, correct=F)

Chi-squared test for given probabilities

data:  Titanic
X-squared = 8335.723, df = 31, p-value < 2.2e-16


One will report results for the 25 df model, the other for the 31 df. ?chisq.test says: "the hypothesis tested is whether the population probabilities [are] equal". While ?summary.table "performs a chi-squared test for independence of factors (note that the function chisq.test currently only handles 2-d tables)."

So, what is the difference between the Chi-squared test for given [equal] probabilities and the Test for independence of all factors? And, more importantly, what is the null model here, and what does it stand for? (Namely in the context of the independence model and the saturated model...)

This question is somewhat related to Test GLM model using null and model deviances...