runehaubo / lmerTestR

Repository for the R-package lmerTest
48 stars 9 forks source link

extreme(?) values of denomintor degress freedom #32

Closed wolski closed 3 years ago

wolski commented 4 years ago

Hello,

I would like to get some p-values from a mixed effects linear model and hence I decided to use the lmerTest package.

However, I am surprised to see very large degrees of freedom for some coefficients (almost equal to the residual degrees of freedom). In the attached model some of the parameters have almost 530 df while the intercept for instance has only 12. I would expect degrees of freedom for all coefficient to be of the same order.

library(lmerTest)
mb <- readRDS(url("https://github.com/runehaubo/lmerTestR/files/4045186/mb.zip"))
formula(mb)

also please note that we have 13 levels in the random effect.

length(unique(mb@frame$peptide_Id))
#13 

and 536 residual degrees of freedom

> df.residual(mb)
[1] 536

Hence, I am guessing that there should no more than 536/13 n's for parameter estimation (Because If I aggregated the repeated measurements modelled using the peptide_Id variable this would reduce the size of the data by this factor).

Not sure therefore, what to think about the df estimates obtained?

summary(mb)
Fixed effects:
                   Estimate Std. Error        df t value Pr(>|t|)   
(Intercept)        -0.70171    0.34529  12.41018  -2.032  0.06411 . 
class_therapyc.NO   0.09960    0.06451 525.98898   1.544  0.12321   
class_therapyp.NO   0.01728    0.06187 526.00766   0.279  0.78013   
CelltypeHSC         0.13356    0.05086 525.99586   2.626  0.00889 **

Also when using the function contest the degrees of freedom estimates are much more that I would expect.

lmerTest::contest(mb, c( 0 ,1 , 0 , 0),joint=FALSE)

Could you please give me advice how to proceed?

> packageVersion("lmerTest")
[1] ‘3.1.0’
runehaubo commented 4 years ago

Sorry for the late reply. We are seeing some changes in the lmerTest team which are causing the delay - we will be back with a follow-up as soon as possible.

Cheers Rune

sofpj commented 4 years ago

Sorry for the late reply.

The denominator degrees of freedom, when testing the two fixed effects (celltype and class_therapy) is in this case the residual degrees of freedom, which is equal to 542-16=526, where 16 is the number of free parameters in the model. If the model included the random interaction between the fixed effects and the random effect, the denominator degrees of freedom would be lower, since the fixed effects would be tested against the random interaction and not the error. The df for the (Intercept) is only around 12 since it is tested against the random effect.

In other words, the degrees of freedom are completely okay and not a mistake. You would get very similar results when using e.g. proc mixed in SAS.

Hope it clarified things a bit?

Cheers, Sofie