Search code examples
rspss

R and SPSS returning different parameters for loglinear analysis


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


Solution

  • 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.