Skip to content
Prev 10349 / 20628 Next

using weights=varIdent in lme: how to change reference level of grouping factor?

Emma Knight <emma_knight at ...> writes:
Good question. I would have guessed that re-ordering the factor
would do the trick, but I guess not.

library(nlme)
fm1 <- lme(distance ~ age, random =~age|Subject,
     weights=varIdent(form=~1|Sex),data=Orthodont)
fm1$modelStruct$varStruct
## Variance function structure of class varIdent representing
##    Male   Female 
## 1.000000 0.404098 

Orth2 <- transform(Orthodont,
      Sex=factor(Sex,levels=c("Female","Male")))
fm2 <- update(fm1,data=Orth2)
summary(model.frame(fm2))
fm2$modelStruct$varStruct
## Variance function structure of class varIdent representing
##    Male   Female 
## 1.000000 0.404098 

  I have spent some time delving through the guts of lme()
but haven't figured it out yet.  I'm somewhat baffled,
as the default order of factor() should be Female, Male in
any case, so I don't see where the order could be getting
messed up.