0
$\begingroup$

Hi there I'm using R to perform some multivariate data analysis on health data. I'm currently using the glm() function with family=poisson to perform the log-linear analysis count~yf*tsf, where count is a vectorised contingency table, and yf and tsf are the category factors for the 2x2 contingency table.

However I also want to model it adjusting for variables age, sex and edu, which I've coded as categorical with 2, 2, and 4 categories respectively. So I have also tried glm(count~yf*tsf+age+sex+edu). Here count is accounting for the 3 extra variables and becomes a 2x2x2x2x4 contingency table. However there seems to be no change in the intercept and p-vals of the common variables between the two models, the interaction term being of particular interest. Can anyone help me figure out if this is normal?

Here's the output from the two models:

Call:
glm(formula = as.vector(count) ~ yf * tsf, family = poisson)

Deviance Residuals: 
[1]  0  0  0  0

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  8.14090    0.01707 476.920  < 2e-16 ***
yf2         -3.32871    0.09177 -36.273  < 2e-16 ***
tsf2         2.12068    0.01806 117.395  < 2e-16 ***
yf2:tsf2    -0.39328    0.09951  -3.952 7.74e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance:  6.0961e+04  on 3  degrees of freedom
Residual deviance: -1.2701e-13  on 0  degrees of freedom
AIC: 45.107

Number of Fisher Scoring iterations: 2

Second model:

Call:
glm(formula = as.vector(count) ~ yf * tsf + sexf + agf + eduf, 
    family = poisson)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-14.6551   -3.4560    0.7385    2.4046   14.1452  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  6.02008    0.02005 300.221  < 2e-16 ***
yf2         -3.32871    0.09177 -36.273  < 2e-16 ***
tsf2         2.12068    0.01806 117.395  < 2e-16 ***
sexf2       -0.16551    0.01107 -14.950  < 2e-16 ***
agef2        -1.24170    0.01323 -93.863  < 2e-16 ***
eduf2       -1.24946    0.02187 -57.131  < 2e-16 ***
eduf3        0.46624    0.01317  35.405  < 2e-16 ***
eduf4       -0.47650    0.01668 -28.570  < 2e-16 ***
yf2:tsf2    -0.39328    0.09951  -3.952 7.74e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

    Null deviance: 84216.5  on 63  degrees of freedom
Residual deviance:  2029.3  on 55  degrees of freedom
AIC: 2437.7

Number of Fisher Scoring iterations: 5
$\endgroup$

1 Answer 1

1
$\begingroup$

Yes that is normal. In a log-linear model the main effects only "control" for the margins of your table, and the odds ratios are designed to be independent of these margins. To get the equivalent of including a variable in a (logistic) regression you also need to include interaction terms.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.