After doing the regression using lm
for fixed effect model or lmer
for mixed effects model, I pass the results to the logLik
. Besides the value of log-likelihood, the function always returns a df
, i.e. the degree of freedom.
However, the degree of freedom does not equal to the number of parameters in the model, df
always larger. So what does the df
mean exactly?
The reason I care about the df
is that later I will use the BIC
(Bayesian Information Criterion) to do the model selection. The BIC is defined as
BIC=-2*logLik+k*log(n)
where k
is the number of parameters and n
is the number of observations. When I pass my logLik
value to the expression of BIC
, the result is exactly the same when I use the build in BIC
function in R
if I specify the number of parameters as the df
in logLik
. Which means, in the build in BIC
function, they also use the df
as k
when they calculate BIC
.