Skip to content
Prev 252 / 20628 Next

estimated growth curves from lme4

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
Message-ID: <fc.004c4d1931837e563b9aca00adcd95d6.3183d248@umit.maine.edu>
In-Reply-To: <mailman.19.1184580009.27115.r-sig-mixed-models@r-project.org>