[R] AIC questions

Joe Yarmus joseph.yarmus at oracle.com
Thu Sep 27 15:56:11 CEST 2007


Digging into the R-code behind AIC for gaussian family models, I see:
AIC = nobs * (log(dev/nobs * 2 * pi) + 1) + 2 - sum(log(wt)) + 2 * p
dev = sum(wt * (y - mean(y))^2
For the unweighted case, this translates directly to -2LL with the 
penalty number of parameters including both intercept and error term (as 
represented by the constant + 2) and the unknown sigma-squared = sum((y 
- mean(y)^2)/ nobs (rather than nobs-1). However, with weights, I am at 
a loss to understand the expression, because, given
-2LL = nobs * (log(2 * pi * sigma^2) + sum(wt * (y - mean(y))^2/sigma^2
if sigma^2 = sum(wt * (y - mean(y))/sum(wt)
then
-2LL = nobs * (log(2 * pi *dev/nobs) + log(nobs) - log(sum(wt)) + sum(wt)
so if wt = 1 all is fine because
-2LL = nobs * (log(2 * pi * dev/nobs) + 1)
What am I missing? Thanks!

   -joe yarmus



More information about the R-help mailing list