[R-sig-ME] estimated growth curves from lme4
Alan Cobo-Lewis
alanc at umit.maine.edu
Mon Jul 16 16:05:39 CEST 2007
Setting aside the knotty question of standard errors, is it really unclear what predict() should do in this case?
fixef(), resid(), and ranef() all work, and the help entry for ranef() says that it returns an object that is "A list of data frames, one for each grouping factor for the random effects." So where predict.lme() has a level argument, couldn't
predict() for mer objects have a grouping.factor argument that was a vector of which grouping factors should be considered in generating the predictions? Alternatively, grouping.factor could be a list of numeric vectors.
In cases where predict.lme() has scalar level= , predict() for mer objects would have vector or scalar grouping.factor=
In cases where predict.lme() has vector level=, predict() for mer objects would have grouping.factor=list()
Something like this:
fm1.lme <- lme(pixel ~ day + I(day^2), data = Pixel, random = list(Dog = ~ day, Side = ~ 1))
fm1.lmer <- lmer(pixel ~ day + I(day^2) + (day|Dog)+ (1|Side:Dog), data = Pixel )
# To generate vector of fixed-effect predictions based on ~day+I(day^2):
predict( fm1.lme, level=0 )
predict( fm1.lmer, grouping.factor=0 )
# To generate vector of predictions based on ~day+I(day^2)+(day|Dog):
predict( fm1.lme, level=1 )
predict( fm1.lmer, grouping.factor=1 )
# To generate vector of predictions based on ~day+I(day^2)+(day|Dog)+(1|Side:Dog):
predict( fm1.lme, level=2 )
predict( fm1.lmer, grouping.factor=1:2 )
# To generate vector of predictions based on ~day+I(day^2)+(1|Side:Dog)
# can't do it in lme
predict( fm1.lmer, grouping.factor=2 )
# To generate data.frame of fixed-effect preds, Dog-specific preds, and Side-specific preds:
predict( fm1.lme, level=0:2 )
predict( fm1.lmer, grouping.factor=list(0, 1, 1:2) ) # inclusion of fixed effect in prediction equation is implicit in 2nd and 3rd elements of grouping.factor
predict( fm1.lmer, grouping.factor=list(0, 0:1, 0:2) ) # equivalent to line above. Inclusion of fixed effect in all three prediction equations is now explicit
Obviously easier to describe than to implement! But is there anything obviously wrong with the description?
alan
Date: Sun, 15 Jul 2007 06:54:22 -0500
From: "Douglas Bates" <bates at stat.wisc.edu>
Subject: Re: [R-sig-ME] estimated growth curves from lme4
To: "Afshartous, David" <afshart at exchange.sba.miami.edu>
Cc: r-sig-mixed-models at r-project.org
Message-ID:
<40e66e0b0707150454y3efc4ae9l2e1375dc82e01e96 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>> It is trickier to define the predictions should be when you want to
>> incorporate the random effects. If you incorporate all the "levels" of
>> the random effects I think it is clear what the prediction should be.
>> Defining a standard error for that prediction could be difficult - I'm
>> not sure. However, I don't know what the answer should be if you only
>> incorporate some of the random effects. We could define that
>> unambiguously for lme models because the grouping factors were required
>> to be nested. Because lmer allows for fully crossed or partially crossed
>> grouping factors the concept of levels is lost. That is, there is no
>> strict hierarchy in the grouping factors and we can't levels to define
>> predictions.
More information about the R-sig-mixed-models
mailing list