5
$\begingroup$

I am conducting a mixed model, but do not well understand how df is calculated, can someone help me to clarify it? I have been searching very hard on the internet but could not find the right answer.

The data in fact contains Animal as random effect, Breed and DFC (day from calving) and squared_DFC as fixed effect, and Red My as the response variable. The mixed model is:

model <- lme(Red_MY ~ DFC + DFC*Breed, random=~1|Animal, 
             data= my_data)

The output:

Red_BW ~ DFC + DFC * Breed + Squared_DFC
    
Linear mixed-effects model fit by REML
 Data: na.omit(my_data) 
       AIC     BIC    logLik
  24045.02 24086.5 -12015.51

Random effects:
 Formula: ~1 | Cow_code
        (Intercept) Residual
StdDev:    7.700506 17.80507

Fixed effects: Red_BW ~ DFC + DFC * Breed + Squared_DFC 
                       Value Std.Error   DF   t-value p-value
(Intercept)        2.3266511 2.4810473 2688  0.937770  0.3484
Centred_DFC       -0.0232875 0.0080565 2688 -2.890523  0.0039
Breed             -1.3165288 1.1309444   80 -1.164097  0.2478
Squared_DFC       -0.0003436 0.0000345 2688 -9.957905  0.0000
Centred_DFC:Breed -0.0115884 0.0037693 2688 -3.074444  0.0021
 Correlation: 
                  (Intr) DFC Breed  Sq_DFC
Centred_DFC        0.061                     
Breed             -0.912 -0.060              
Squared_DFC       -0.183  0.002  0.009       
Centred_DFC:Breed -0.063 -0.924  0.067  0.026

Standardized Within-Group Residuals:
         Min           Q1          Med           Q3          Max 
-4.649177035 -0.562679661 -0.004077324  0.521083911  8.448741285 

Number of Observations: 2773
Number of Groups: 82    
$\endgroup$
1
  • 3
    $\begingroup$ It's in Pinheiro and Bates (2000): see tinyurl.com/ntygq3 for the relevant page on Google Books. $\endgroup$
    – Ben Bolker
    Commented Nov 22, 2013 at 14:30

1 Answer 1

1
$\begingroup$

I follow @BenBolker's advice and look up the formula in (Pinheiro and Bates, 2000); it's on page 91. $$ \operatorname{DF}_i = m_i - \left(m_{i-1} + p_i\right) $$ where $m_i$ is the number of groups on level $i$ (with $m_0 = 1$ when the fixed effects include an intercept and $m_0 = 0$ otherwise), and $p_i$ is the number of (effective) parameters at level $i$.

Let's determine the $m_i$s and $p_i$s for the OP's model. This linear mixed model has two levels, one for the animals and one for the observations. Therefore:

m_0 <- 1    # the model has an intercept term
m_1 <- 82   # number of groups (animals)
m_2 <- 2773 # number of observations

Moreover, there is one group-level predictor Breed (each animal is of a specific breed) and three individual-level predictors (DFC, DFC2 and the interaction between DFC and Breed).

p_1 <- 1 # one degree for Breed
p_2 <- 3 # one degree each for Centered_DFC, Squared_DFC, Centred_DFC:Breed

Note: The model treats both DFC (days from calving) and Breed as numeric. This makes sense for DFC (and its two transformations, Centered_DFC and Squared_DFC) but it won't make sense for Breed unless there are only two breeds coded as 0 and 1.

Finally, we calculate the (denominator) degrees of freedom according to the (Pinheiro and Bates, 2000) formula.

denDF_1 <- m_1 - (m_0 + p_1)
denDF_2 <- m_2 - (m_1 + p_2)

denDF_1
#> [1] 80
denDF_2
#> [1] 2688

This matches that degrees of freedom (DF) reported in the summary table.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.