# Degrees of Freedom Calculation in Linear Mixed Model

How are degrees of freedom calculated for a linear mixed effects model? I was recently running a linear mixed effects model that contained 1 independent variable with 3 levels (1,2, and 3). The random effects included: individual animal ID and year as I expected these variables to account for some of the variability in the modelling procedure and wanted to make sure to account for it. However, to obtain the P-value, I ran a null model containing only the intercept and random effects and compared it via the anova() command to the full model. The degrees of freedom just seem a little odd given that the random effect for individual animal ID contains 171 individuals across 3 years. Any help would be much appreciated!

fit.lmer.model <- lmer(MCP ~ Season +(1|ID)+(1|Year), data=mydataframe,REML=FALSE)
summary(fit.lmer.model)

fit.lmer.null <- lmer(MCP ~ 1 + (1|ID)+(1|Year), data=mydataframe,REML=FALSE)
summary(fit.lmer.null)

anova(fit.lmer.null,fit.lmer.model)

> anova(fit.lmer.null,fit.lmer.model)
Data: mydataframe
Models:
fit.lmer.null: MCP ~ 1 + (1 | ID) + (1 | Year)
fit.lmer.model: MCP ~ Season + (1 | ID) + (1 | Year)
Df    AIC    BIC  logLik deviance Chisq Chi Df Pr(>Chisq)
fit.lmer.null   4 2240.0 2252.6 -1116.0   2232.0
fit.lmer.model  5 2238.2 2253.9 -1114.1   2228.2 3.759      1    0.05252 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


The degrees of freedom shown are the number of estimated parameters in the model. In the fit.lmer.null model you have a parameter for the intercept, a variance parameter for each random effect term and a variance parameter for the observations given the random effects (called "Residual" if you run summary(fit.lmer.null)). That is a total of four parameters. The principle is the same for the other model, you just have one more parameter from "Season".