Solved – get equal AIC, BIC and log likelihood for different models in LME framework

I have two LME models with the same interaction, one containing both main effects and one containing only one main effect, say :

$$ H_CE = Season + Crownlevel + Season:Crownlevel , random = 1|CollectorID $$
$$ H_CE = Season + Season:Crownlevel , random = 1|CollectorID $$

There are 4 levels of each, and every combination of Season, Crownlevel and CollectorID
The AIC, BIC and log likelihood of both models are completely equal. Given the formula for AIC being

$$ mathit{AIC} = 2k – 2ln(L) $$

one would expect this to be different, even if the likelihoods are exactly the same. In the end, they have a different number of parameters. Or so I thought…

Trying this toy example in R :

library(nlme)  Season <- rep(as.factor(rep(letters[1:4],each=4)),4) Crownlevel <-rep(as.factor(rep(letters[11:14],4)),4) CollectorID <-rep(letters[20:23],each=16) X <-  model.matrix(~Season+Crownlevel+Season:Crownlevel) B <- c(1,1,-2,2,0.3,0.4,0.4,2,3,1,-2,-3,-4,2,1,2) H_CE <- X %*% B + rnorm(16*4) KBM <- data.frame(Season,Crownlevel,H_CE,CollectorID)  model1 <- lme(H_CE~Season+Crownlevel+Season:Crownlevel,data=KBM,        method="ML",random=~1|CollectorID) model1e <- lme(H_CE~Season+Season:Crownlevel,data=KBM,        method="ML",random=~1|CollectorID) 

I get :

anova(model1,model1e)         Model df      AIC      BIC    logLik model1      1 18 174.1834 213.0433 -69.09168 model1e     2 18 174.1834 213.0433 -69.09168 

What am I missing here? Why are the numbers completely equal? It has to do something with the model specification, but I can't really see what.

The model specification in itself is faulty, I know that. But I can't explain what makes it return a different set of parameters, but exactly the same residuals, likelihood and degrees of freedom :

> all.equal(residuals(model1),residuals(model1e)) [1] TRUE 

As fabians rightfully pointed out, both models are perfectly equivalent. Yet, I fail to see why in the AIC calculation the same value for the number of parameters k is used.

The k in AIC uses the df, which explains everything.

The models are exactly equivalent. In both models you effectively specify one parameter for each combination of levels of Season and Crownlevel – the only difference is the parameterization:

In the first model, you fit main effects for Season and Crownlevel and an interaction effect to capture the combination-specific deviations from the main effects.

In the second model, you specify only the main effect of season, and the interaction effect then captures the deviations for each crownlevel within a season.


would also yield an equivalent model, with one parameter for each combination of season and crownlevel (minus one that is non-identifiable because of the intercept, i.e. constitutes the reference category).

BTW: I don't think your model specification is faulty, which specification is better depends on the inference you want to do with your model.

Similar Posts:

Rate this post

Leave a Comment