Development

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Linear Trend in Residiuals From lme

    5 answers - 571 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    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?
    Rick B.
    R-help (AT) stat (DOT) math.ethz.ch mailing list
    PLEASE do read the posting guide
    and provide commented, minimal, self-contained, reproducible code.
  • No.1 | | 1019 bytes | |

    8/9/06, Rick Bilonick <rab45+@pitt.eduwrote:
    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.

    R-help (AT) stat (DOT) math.ethz.ch mailing list

    PLEASE do read the posting guide
    and provide commented, minimal, self-contained, reproducible code.
  • No.2 | | 1713 bytes | |

    Wed, 2006-08-09 at 15:04 -0500, Douglas Bates wrote:
    8/9/06, Rick Bilonick <rab45+@pitt.eduwrote:
    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 (AT) stat (DOT) math.ethz.ch mailing list

    PLEASE do read the posting guide
    and provide commented, minimal, self-contained, reproducible code.
  • No.3 | | 1312 bytes | |

    Wed, 2006-08-09 at 15:04 -0500, Douglas Bates wrote:
    8/9/06, Rick Bilonick <rab45+@pitt.eduwrote:
    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.

    I tried using geeglm from geepack to fit a marginal model. I understand
    this is not the same as a mixed effects model but the residuals don't
    have the linear trend. Should I avoid using lme in this case?

    Rick B.

    R-help (AT) stat (DOT) math.ethz.ch mailing list

    PLEASE do read the posting guide
    and provide commented, minimal, self-contained, reproducible code.
  • No.4 | | 1365 bytes | |

    8/9/06, Rick Bilonick <rab45+@pitt.eduwrote:
    Wed, 2006-08-09 at 15:04 -0500, Douglas Bates wrote:
    8/9/06, Rick Bilonick <rab45+@pitt.eduwrote:
    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.

    I tried using geeglm from geepack to fit a marginal model. I understand
    this is not the same as a mixed effects model but the residuals don't
    have the linear trend. Should I avoid using lme in this case?

    Probably.

    R-help (AT) stat (DOT) math.ethz.ch mailing list

    PLEASE do read the posting guide
    and provide commented, minimal, self-contained, reproducible code.
  • No.5 | | 1326 bytes | |

    As an extreme example of this sort of thing, consider

    fit <- lme(y ~ 1, random = ~ 1 | group)

    where there is exactly one observation per group, so that it is not possible to
    get separate estimates of group and residual variances. Despite this, lme
    often (always?) provides a solution consistent with the data. Because of the
    singularity, the plot of residuals against fitted values for this solution
    shows a straight line. This is easily recognized as an aberration, but I can
    imagine configurations of data (e.g. with most groups having just one
    observation and a few with two or more) where the residual vs fitted value plot
    might show an apparent trend.

    Wed, Aug 09, 2006 at 03:43:12PM -0400, Rick Bilonick 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?

    Rick B.

    R-help (AT) stat (DOT) math.ethz.ch mailing list

    PLEASE do read the posting guide
    and provide commented, minimal, self-contained, reproducible code.

Re: Linear Trend in Residiuals From lme


max 4000 letters.
Your nickname that display:
In order to stop the spam: 4 + 3 =
QUESTION ON "Development"

EMSDN.COM