I did an experiment to look at the influence of two categorial variables onto a categorial output. The input variables were T and P. The output variable is R. Sample size is 188 data-points.
I did a $\chi^2$-test for T and R. The result for Pearson's $\chi^2$ was significant with $\chi^2(4)=122.39, p=1.65e-25$, Cramer's V=0.57 showed a large effect.
ct=xtabs(~ R+ T, data)
chisq.test(ct)
##
## Pearson's Chi-squared test
##
## data: ct
## X-squared = 122.39, df = 4, p-value < 2.2e-16
The values for P and R were $\chi^2(6)=19.531, p=0.0034$, Cramer's V=0.228 (medium effect).
Then I did a log-linear analysis.
ct=xtabs(~ R + T + P, data)
sm=loglm( ~ P * T * R, ct)
Deleting the threeway interaction T:P:R gave $P(>Delta(Dev))=0.993$ from the saturated model, indicating that the threeway-interaction is not significant ($\chi^2(12)=3.33$).
ni=update(sm, .~. - P:T:R)
anova(sm, ni)
LR tests for hierarchical log-linear models
Model 1:
. ~ P + T + R + P:T + P:R + T:R
Model 2:
~P * T * R
Deviance df Delta(Dev) Delta(df) P(> Delta(Dev)
Model 1 3.330479 12
Model 2 0.000000 0 3.330479 12 0.99273
Saturated 0.000000 0 0.000000 0 1.00000
Deleting T:R from the model without threeway-interaction (retaining P:R) gave $P(>Delta(Dev))=0.000$, so the twosided-interaction T:R is significant:
m1=update(ni, .~. - T:R)
anova(ni, m1)
## LR tests for hierarchical log-linear models
##
## Model 1:
## . ~ P + T + R + P:T + P:R
## Model 2:
## . ~ P + T + R + P:T + P:R + T:R
##
## Deviance df Delta(Dev) Delta(df) P(> Delta(Dev)
## Model 1 109.751132 16
## Model 2 3.330479 12 106.420653 4 0.00000
## Saturated 0.000000 0 3.330479 12 0.99273
But deleting P:R from the model without threeway-interaction (but retaining T:R interaction) gave $P(>Delta(Dev))=0.105$, P thus not being significant to account for the output R:
m2=update(ni, .~. - P:R)
anova(ni, m2)
## LR tests for hierarchical log-linear models
##
## Model 1:
## . ~ P + T + R + P:T + T:R
## Model 2:
## . ~ P + T + R + P:T + P:R + T:R
##
## Deviance df Delta(Dev) Delta(df) P(> Delta(Dev)
## Model 1 13.820419 18
## Model 2 3.330479 12 10.489940 6 0.10548
## Saturated 0.000000 0 3.330479 12 0.99273
I do not understand how to interpret this: How can the $\chi^2$-test show a significant medium effect for P:R while leaving out this term from the hierarchical loglinear analysis shows that P:R is not significant?
