I am using the R package nlme to perform a repeated measure analysis. The model call is mymodel<-lme(measure~time, data=mydata[is.finite(mydata$measure),], random= ~ 1 | subjectId/time). I would like to provide an estimate of the standard error of residual, by means the residual after the time effect (the pure random residual). When observing the model call I get:

Linear mixed-effects model fit by REML
 Data: mydata[is.finite(mydata$measure), ] 
  AIC BIC logLik
  182 190  -83.9

Random effects:
 Formula: ~1 | subjectId
StdDev:        4.42

 Formula: ~1 | time %in% subjectId
        (Intercept) Residual
StdDev:        4.43     1.89

Fixed effects: measure ~ time 
                Value Std.Error DF t-value p-value
(Intercept)     13.80      2.07 16    6.68   0.000
timePost        -1.44      2.34 16   -0.61   0.548
timePost 2 mesi -2.21      2.59 16   -0.85   0.406
timePost 4 mesi -2.31      2.77 16   -0.84   0.416
                (Intr) timPst tmPs2m
timePost        -0.479              
timePost 2 mesi -0.433  0.426       
timePost 4 mesi -0.405  0.398  0.369

Standardized Within-Group Residuals:
    Min      Q1     Med      Q3     Max 
-0.5487 -0.1739 -0.0217  0.2025  0.6455 

Number of Observations: 29
Number of Groups: 
          subjectId time %in% subjectId 
                 10                  29

So i find two measures of residuals: 4.42, 4.43/1.89, that appears different from the one I get calling sd(residuals(mymodel)) that In my basing intuition is the traditional meausre of residual. So my question is twofolds:

  1. What are the different type of residuals in nlme/lme4 or in mixed effects modeling in general?
  2. How can I get the various ones?
  3. How can I get the residuals after any modelable effects (fixed or random)? I would use sd(residuals(mymodel)) but I am not sure.

1 Answer 1


Your question is too broad for me to answer in its entirety, but I will focus on the lme() portion of the question.

When working with the lme() function in the nlme package, you have the option of producing various types of residuals, as follows.

Raw residuals:

  • conditional: resid(mymodel, type="response")

  • marginal: resid(mymodel, type="response", level=0)

Normalized residuals:

  • conditional: resid(mymodel, type="normalized")

Pearson residuals:

resid(mymodel, type="pearson")

If you refer to pages 265-266 of the book "Linear Mixed-Effects Models Using R: A Step-by-Step Approach" by Galecki and Burzykowski (Springer, 2013), you will find a comprehensive description on the usefulness of each type of residuals.


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.