Hello, after calculating a multinomial logit regression on my data, I
compared the output to an output retrieved with SPSS 18 (Mac). The
coefficients appear to be the same, but the logLik (and therefore fit)
values differ widely. Why?

The regression in R:

set.seed(1234)
df <- data.frame(
  "y"=factor(sample(LETTERS[1:3], 143, repl=T, prob=c(4, 1, 10))),
  "a"=sample(1:5, 143, repl=T),
  "b"=sample(1:7, 143, repl=T),
  "c"=sample(1:2, 143, repl=T)
)
library(nnet)
mod1 <- multinom(y ~ ., data=df, trace=F)
deviance(mod1) # 199.0659
mod0 <- update(mod1, . ~ 1, trace=FALSE)
deviance(mod0) # 204.2904

Output data and syntax for SPSS:

df2 <- df
df2[, 1] <- as.numeric(df[, 1])
write.csv(df2, file="dfxy.csv", row.names=F, na="")
syntaxfile <- "dfxy.sps"
cat('GET DATA
  /TYPE=TXT
  /FILE=\'', getwd(), '/dfxy.csv\'
  /DELCASE=LINE
  /DELIMITERS=","
  /QUALIFIER=\'"\'
  /ARRANGEMENT=DELIMITED
  /FIRSTCASE=2
  /IMPORTCASE=ALL
  /VARIABLES=
  y "F1.0"
  a "F8.4"
  b "F8.4"
  c "F8.4".
CACHE.
EXECUTE.
DATASET NAME DataSet1 WINDOW=FRONT.

VALUE LABELS
  /y 1 "A" 2 "B" 3 "C".
EXECUTE.

NOMREG y (BASE=1 ORDER=ASCENDING) WITH a b c
  /CRITERIA CIN(95) DELTA(0) MXITER(100) MXSTEP(5) CHKSEP(20)
LCONVERGE(0) PCONVERGE(0.000001)
    SINGULAR(0.00000001)
  /MODEL
  /STEPWISE=PIN(.05) POUT(0.1) MINEFFECT(0) RULE(SINGLE)
ENTRYMETHOD(LR) REMOVALMETHOD(LR)
  /INTERCEPT=INCLUDE
  /PRINT=FIT PARAMETER SUMMARY LRT CPS STEP MFI IC.
', file=syntaxfile, sep="", append=F)

-> Loglik0: 135.02
-> Loglik1: 129.80

Thanks, Sören

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to