JenniNiku / gllvm

Generalized Linear Latent Variable Models
https://jenniniku.github.io/gllvm/
49 stars 20 forks source link

AICc smaller than AIC #4

Closed RodolfoPelinson closed 3 years ago

RodolfoPelinson commented 5 years ago

Hi. I noticed that for my data set, AICc was always smaller than AIC. It didn't make sense to me since AICc is AIC plus a penalty. I looked into how information criteria is computed in the code and saw that AICc <- AIC + 2*k*(k+1)/(n-k-1) where n is n <- dim(abund)[1] the number of rows of the abundance matrix.

So, as I understood, if the number of covariates increases, k increases by a lot when the number of species is large. With such a large k the penalty 2*k*(k+1)/(n-k-1) easily becomes a negative value, making models with more parameters almost always "better". Is that right?

Shouldn't n be the number of rows (sample sites) times the number of columns (species)?

BertvanderVeen commented 3 years ago

Sorry for the late response. I've been thinking about this (and spoken with @JenniNiku), and agree with the correct number of observations being p*n. I have added a "fix" in my newest pull request.