0

I ran a loglinear analysis in R on the following graduate admissions data.

grad_admissions <- array(data = c(39, 10, 20, 15, 11, 41, 6, 60), 
                         dim = c(2,2,2), 
                         dimnames = list("department" = c("one","two"),
                                         "gender" = c("male","female"),
                                         "admission" = c("admitted","notadmitted")))

ftable(grad_admissions, row.vars = c("department"),col.vars = c("admission","gender"))

grad_admissions.df <- as.data.frame(as.table(grad_admissions))

grad_admissions.df$gender <- factor(grad_admissions.df$gender, levels = c("female","male"))
grad_admissions.df$department <- factor(grad_admissions.df$department, levels = c("two","one"))
grad_admissions.df$admission <- factor(grad_admissions.df$admission, levels = c("admitted","notadmitted"))


mod1 <- glm(Freq ~ department * gender * admission, 
            data = grad_admissions.df, family = poisson)

summary(mod1)

I also ran the following SPSS Syntax on the same dataset (SAV file here).

DATASET ACTIVATE DataSet2.
WEIGHT BY Count.

GENLOG Gender Admitted Department
  /MODEL=POISSON
  /PRINT=FREQ RESID ADJRESID ZRESID DEV ESTIM CORR COV
  /PLOT=NONE
  /CRITERIA=CIN(95) ITERATE(20) CONVERGE(0.001) DELTA(.5).

The parameter estimates are below. They are similar but not quite the same. In the SPSS output male is coded as 0 and female as 1.

Can anyone explain why they are not the same?

SPSS vs R output

  • Back of my mind I recall 'because they're being calculated differently', so it comes down to the formulas used. Which I know isn't very helpful, but your have the help files for both along the flow of calculation. – Chris Apr 19 '20 at 13:31
  • This might offer some illumination: https://stats.stackexchange.com/questions/178492/which-optimization-algorithm-is-used-in-glm-function-in-r – Kevin Troy Apr 20 '20 at 14:00

1 Answers1

2

Try the following:

GENLOG Department Gender Admitted
  /MODEL=POISSON
  /PRINT=FREQ RESID ADJRESID ZRESID DEV ESTIM CORR COV
  /PLOT=NONE
  /CRITERIA=CIN(95) ITERATE(20) CONVERGE(0.001) DELTA(0).

Note the DELTA(0) specification on the CRITERIA subcommand. SPSS GENLOG by default adds .5 to the cell count for each cell in a saturated model, a common technique for handling 0 cell counts in loglinear models.

David Nichols
  • 576
  • 3
  • 5