I find that there are two ways to calculate AIC:
AIC = -2ln(likelihood)+ 2K and
AIC = n*ln(RSS/n)+2K
I have:
crf <- c(0.3333333, 0.5000000, 0.6666667, 0.6666667, 0.6666667, 0.8333333, 0.1666667, 0.3333333, 0.5000000, 0.5000000, 0.8333333, 0.5000000,0.6666667, 0.5000000, 0.6666667, 1.0000000)
co3 <- c(218.20, 243.84, 267.97, 286.31, 315.01, 315.01, 241.09, 242.52, 243.84, 245.04, 246.10, 284.15, 285.79, 287.31, 288.67, 289.49)
n <- length(crf)
model <- lm(crf ~ co3) #y=ax+b
aic1 <- AIC(model, k=2)
RSS <- sum(resid(model)^2)
aic2 <- n*log(RSS/n) + 2*3
I have aic1=-7.220462 and aic2= -52.62649
but if I will do like this:
aic3 <- n + n*log(2*pi) + n*log(RSS/n) + 2*3
I have aic3=-7.22046. I don't understand why, everywhere it is written that
AIC = n*ln(RSS/n)+2K, what is this term n + n*log(2*pi)?