Skip to content
Prev 32379 / 398513 Next

basic question on getGroups for lme analyses

As far as I know GetGroups is designed to extract grouping factors from an 
object, not to create them . To do so you can either specify your hierarchy 
in the random argument of your lme model .i.e. m1<-lme(distance~age, 
data=Orthodont, random = ~age|Subject)

or you can also create grouped data using groupedData.i.e:

groupedData( distance ~ age | Subject,
                   data = as.data.frame( Orthodont ),
                   FUN = mean,
                   outer = ~ Sex,
                   labels = list( x = "Age",
                     y = "Distance from pituitary to pterygomaxillary 
fissure" ),
                   units = list( x = "(yr)", y = "(mm)") )

     plot( Orth.new )         # trellis plot by Subject

     formula( Orth.new )      # extractor for the formula
     gsummary( Orth.new )     # apply summary by Subject
     fm1 <- lme( Orth.new )   # fixed and groups formulae extracted from 
object
     Orthodont2 <- update(Orthodont, FUN = mean)