[R] Different LLRs on multinomial logit models in R and SPSS

David Winsemius dwinsemius at comcast.net
Thu Jan 6 17:16:03 CET 2011


On Jan 6, 2011, at 11:06 AM, Sören Vogel wrote:

> 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 likelihood is arbitrary. It is the difference in likelihoods that  
is important and in this respect the answers you got from the two  
software packages (delta deviance= 5.22) is equivalent. If you run  
logistic models with individual records versus using grouped data for  
equivalent models with the same software, the reported deviance will  
be widely different but the comparison of nested models will imply the  
same inferential conclusions.

-- 
David.
>
> 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 at 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list