2

Let consider this simple model consisting in two independent random effects:

$$y_{ijk} = \mu + \delta1_i + \delta2_j + \epsilon_{i,j,k}$$

where \delta1_i and \delta2_j are independent random effect (i.e. \delta1_i \sim N(0,\sigma_1^2) iid, \delta2_i \sim N(0,\sigma_1^2) iid, both independent).

Defining and inferring the variance components of such a model is straightforward using lme4::lmer (sorry the example below is likely to have no physical meaning) :

library(lme4)
library(nlme)
data(Orthodont,package="nlme")   

lmer(data=Orthodont,distance~1+(1|Sex)+(1|Subject))
#Linear mixed model fit by REML ['lmerMod']
#Formula: distance ~ 1 + (1 | Sex) + (1 | Subject)
#   Data: Orthodont
#REML criterion at convergence: 510.3937
#Random effects:
# Groups   Name        Std.Dev.
# Subject  (Intercept) 1.596   
# Sex      (Intercept) 1.550   
# Residual             2.220   
#Number of obs: 108, groups:  Subject, 27; Sex, 2
#Fixed Effects:
#(Intercept)  
#      23.83 

How can this be modeled easily using nlme::lme ? Specifying the random effect using a list of random effect implicitly introduces interaction depending from the ordering of the random effects , which can be verified here (changing order of specification, change results):

VarCorr(lme(data=Orthodont,distance~1,random=list(~1|Subject,~1|Sex)))
#            Variance     StdDev  
#Subject =   pdLogChol(1)         
#(Intercept) 1.875987     1.369667
#Sex =       pdLogChol(1)         
#(Intercept) 1.875987     1.369667
#Residual    4.929784     2.220312

VarCorr(lme(data=Orthodont,distance~1,random=list(~1|Sex,~1|Subject)))
#            Variance     StdDev  
#Sex =       pdLogChol(1)         
#(Intercept) 2.403699     1.550387
#Subject =   pdLogChol(1)         
#(Intercept) 2.546702     1.595839
#Residual    4.929784     2.220312
beuhbbb
  • 257
  • 3
  • 14
  • your `StdDev` in the `lmer` results match the `StdDev` in the second `lme` model, if you switch `sex` and `subject` in `lmer` would that also change the results? Also if you do not want an interaction, you *might* be able to create a new variable like `nv = paste0(Sex,Subject)`, and use `nv` in your model instead of `Sex` and `Subject`. I am not sure of the interpretation of that – Mike Sep 13 '18 at 13:23
  • @Mike. Thks for your comment. No, changing the order in lmer does not change the result. Creating a new label for the Sex Subject Combination does not solve my problem as I precisely want to estimate the magnitude of each random effect. – beuhbbb Sep 13 '18 at 14:41
  • Ok I found this post on cross validated that might help you, although the answer to this question is 5 years old now :https://stats.stackexchange.com/questions/58669/specifying-multiple-separate-random-effects-in-lme – Mike Sep 13 '18 at 21:07
  • @Mike. Thanks but actually the notations (list(Sex=~1,Subject=~1)) provided in your reference gives the same problem than in the lme example given in my question. – beuhbbb Sep 14 '18 at 07:36
  • May I ask why you want to use `nlme::lme`? – Anders Ellern Bilgrau Sep 15 '18 at 18:48
  • @Anders Ellern Bilgrau. Of course ! Actually, I want then to allow variances for different groups to be not equal and this cannot be done with lme4::lmer but can using nlme::lme. Thks for your interest – beuhbbb Sep 16 '18 at 13:58
  • Have you found an answer? – Rafs Nov 04 '20 at 16:22

0 Answers0