[R] Piecewise regression in lmer

Douglas Bates bates at stat.wisc.edu
Mon Jan 4 16:36:14 CET 2010


On Mon, Jan 4, 2010 at 6:24 AM, Walmes Zeviani
<walmeszeviani at hotmail.com> wrote:

> AD Hayward wrote:
>>
>> Dear all,
>>
>> I'm attempting to use a piecewise regression to model the trajectory
>> of reproductive traits with age in a longitudinal data set using a
>> mixed model framework. The aim is to find three slopes and two points-
>> the slope from low performance in early age to a point of high
>> performance in middle age, the slope (may be 0) of the plateau from
>> the start of high performance to the end of high performance , and the
>> slope of the decline from the end of high performance to the end of
>> life.
>>
>> I've found the segmented package useful, but it cannot be implemented
>> in a mixed model framework. I've also attempted piecewise regression
>> using this formula in lmer:
>>
>> m<-lmer(repro ~ OTHER FIXED EFFECTS + age*(age < 2) + age*(age >= 2 &
>> age < 8) + age*(age >= 8) + (1|id) + (1|yr), data = reproduction,
>> family = binomial, link = "logit", GHQ = TRUE)
>>
>> However, this gives the warning:
>>
>> Warning message:
>> In mer_finalize(ans) : gr cannot be computed at initial par (65)
>>
>> which is not apparent if I use just two break points or I implement
>> the model in glm.
>>
>> My question is essentially whether anyone can recommend a method for
>> performing piecewise regression in lmer or another mixed model
>> framework. Any advice would be greatly appreciated.

> Adam,
>
> A segmented linear model, for estimation purposes, is a nonlinear model. It
> requires a iteractive procedure for estimation of fixed effects. You could
> use nlmer() for this.

It appears that Adam is using fixed knot positions, in which case the
segmented model is a linear model.  He is also using family = binomial
so it is a generalized linear mixed model, which does require
iterative optimization, but does not require nlmer().



More information about the R-help mailing list