[R] AIC and logLik for logistic regression in R and S-PLUS

Leandra Desousa sousa at ims.uaf.edu
Wed Aug 15 23:05:33 CEST 2007


Dear R users,

I am using 'R' version 2.2.1 and 'S-PLUS' version 6.0; and I loaded the 
MASS library in 'S-PLUS'.

I am running a logistic regression using glm:

---------------------------------------------------------------------------
 > mydata.glm<-glm(COMU~MeanPycUpT+MeanPycUpS, family=binomial, data=mydata)
---------------------------------------------------------------------------

The values in summary(mydata.glm) are identical for 'R' and 'S-PLUS' 
(except that S-PLUS does not return an AIC value).
Here is the summary(mydata.glm):
-------------------------------------------------------------------
 >summary(mydata.glm)
Call:
glm(formula = COMU ~ MeanPycUpT + MeanPycUpS, family = binomial,data = 
mydata)
Deviance Residuals:
  Min       1Q      Median    3Q       Max 
-2.3514  -0.8268  -0.4831   0.8866   1.9864

Coefficients:
             Estimate   std.Error z value Pr(>|z|)
(Intercept)   75.482     41.616    1.814   0.0697 .
MeanPycUpT     1.143      2.867    0.399   0.6902
MeanPycUpS    -2.548      1.225   -2.081   0.0374 *
---
Signif.codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 30.316  on 21  degrees of freedom
Residual deviance: 23.900  on 19  degrees of freedom
AIC: 29.9
--------------------------------------------------------------------


When I use the 'AIC' and the 'logLik' command in 'R' and 'S-PLUS' I get 
different values:

'R'
-----------------
 > AIC(mydata.glm)
[1] 29.89986

 > logLik(mydata.glm)
'log Lik.' -11.94993 (df=3)
-----------------

'S-PLUS'
-----------------
 > AIC(mydata.glm)
[1] 71.03222

 > logLik(mydata.glm)
[1] -31.51611
-----------------

However, if I use the 'extractAIC' command in 'S-PLUS' the returned 
value is the same as the one in 'R'.

'R'
------------------------
 > AIC(mydata.glm)
[1] 29.89986

 > extractAIC(mydata.glm)
[1]  3.00000 29.89986
-------------------------

'S-PLUS'
------------------------
 > extractAIC(mydata.glm)
[1]  3.00000 29.89986
------------------------


*****************************************************
MY QUESTIONS ARE:

1) Which AIC value is the correct one?
2) Which log-likelihood value is the correct one?
3) If  'extractAIC' in 'S-PLUS' and all values in 'R' are the correct 
ones, and the 'AIC' and 'logLik' in 'S-PLUS' values are wrong then:
   Why 'S-PLUS' cannot retrieve a log-likelihood value from my glm 
object('mydata.glm'), even though it is using log-likelihood to 
calculate its residual deviance?
*******************************************************

Thank you for you time and Kind attention.

Sincerely,

Leandra de Sousa
--------------------------------------
Ph.D Candidate
School of Fisheries and Ocean Sciences
Universisty of Alaska Fairbanks
245 O'Neill Bldg.
Fairbanks, AK
99775
e.mail: sousa at ims.uaf.edu



More information about the R-help mailing list