# Re: [R] Linear Trend in Residiuals From lme

From: Rick Bilonick <rab45+_at_pitt.edu>
Date: Thu 10 Aug 2006 - 06:32:51 EST

On Wed, 2006-08-09 at 15:04 -0500, Douglas Bates wrote:
> On 8/9/06, Rick Bilonick <rab45+@pitt.edu> wrote:
> > I'm fitting a mixed effects model:
> >
> > fit.1 <- lme(y~x,random=~1|id,data=df)
> >
> > There are two different observations for each id for both x and y. When
> > I use plot(fit.1), there is a strong increasing linear trend in the
> > residuals versus the fitted values (with no outliers). This also happens
> > if I use random=~x|id. Am I specifying something incorrectly?
>
> Could you provide a reproducible example please?
>
> I suspect that the problem comes from having only two observations per
> level of id. When you have very few observations per group the roles
> of the random effect and the per-observation noise term in explaining
> the variation become confounded. However, I can't check if this is
> the case without looking at some data and model fits.

Unfortunately, I can't send the actual data. I did make a simple intercepts-only example with two observations per group but it does not exhibit the linear trend.

library(nlme)

x <- rnorm(20,5,1)
id <- factor(rep(1:20,each=2))

y <- as.vector(sapply(x,rnorm,n=2,sd=0.2))

df <- data.frame(id,y)
df.gd <- groupedData(y~x|id,data=df)

summary(lme.1 <- lme(y~1,random=~1|id,data=df.gd)) plot(lme.1)

If I fit an intercepts-only model to the actual data, I still see the trend in the residuals.

What other analysis would you suggest?

Rick B.

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu Aug 10 06:37:59 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 10 Aug 2006 - 08:20:35 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.