Very confused by residual degrees of freedom in REML

degrees of freedomf-testlme4-nlmemixed modelr

I am trying to estimate a LMEM model with three fixed effects (two regressors and their interaction) and one random effect (a by-subject random intercept). Both regressors are dichotomous.

I'm using R's lme4 command, and I'm just having some problems understanding the residual degrees of freedom.

The model is below. Per my training, I estimated p-values using a Type III Wald F test with Kenward-Rogers degrees of freedom.

conflict1 <- lmer(neurosynth_conflict ~ contrast*Teen_vs_Adult + (1 | participant_id),dCon)

car::Anova(conflict1, type = 3, test = 'F')

The model converges just fine and the output mostly aligns with my expectations, but I'm just really thrown by the residual degrees of freedom. I get that residual degrees of freedom will almost never be integers under REML, but I don't understand why the values are so different across my regressors? Can anyone help me wrap my head around this?

                             F Df Df.res    Pr(>F)    
(Intercept)            20.0400  1 377.20 1.006e-05 ***
contrast               10.5006  1 496.74  0.001273 ** 
Teen_vs_Adult           2.7166  1 388.47  0.100118    
contrast:Teen_vs_Adult  5.9632  1 499.22  0.014953 *  

```

Best Answer

These degrees of freedom aren't importantly different: they're all large, and that's what matters.

More generally, the residual df will depend a lot on whether the information for a particular comparison comes from comparisons within participant or between participants. Very roughly, the residual df is a sort of $n-p$ number where $n$ is the number of observations and $p$ is the number of parameters you've estimated. If you have a variable that is constant within individuals, the relevant $n$ is going to be the number of individuals; if the variable varies within individuals as well, the relevant $n$ will be larger and might be the total number of observations.

I've got an example here looking at microbiome transplants in mice where one issue was whether the residual df was roughly the number of microbiome donors (8) or roughly the number of mice (206), so the between-donor comparisons have much smaller residual df than the between-mouse comparisons.

Related Question