[R] AIC in glm.fit with intercept

Luke jyzz88 at gmail.com
Thu Jun 16 05:35:53 CEST 2005


More interesting:
lm() works fine to get AIC. I wonder if there is a bug in glm.fit().

>  AIC(lm(myY~0+myX, data=data.frame(myY,myX)))
[1] 38.94657
> AIC(lm(myY~1+myX, data=data.frame(myY,myX)))
[1] -650.9808

-Luke

On 6/15/05, Luke <jyzz88 at gmail.com> wrote:
> Dear R users,
> 
> glm.fit() gave me the same AIC's regardless of TRUE or FALSE intercept option.
> 
> > myX <- as.matrix(1:10)
> > myY <- 3+5*myX
> > foo <- glm.fit(x=myX, y=myY, family = gaussian(link = "identity"), intercept=TRUE)
> > foo$aic
> [1] 38.94657
> > foo <- glm.fit(x=myX, y=myY, family = gaussian(link = "identity"), intercept=FALSE)
> > foo$aic
> [1] 38.94657
> 
> Is my code wrong or is it a bug in glm.fit?
> 
> -Luke
>




More information about the R-help mailing list