An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20070905/9b63aeb4/attachment.pl>
Specifying random effects for multiple covariates via lmer
11 messages · Andy Bush, Douglas Bates, Bush, Andrew J +4 more
On 9/5/07, Andy Bush <ajbush at bellsouth.net> wrote:
While working through the text "Applied Longitudinal Analysis" by Fitzmaurice, Laird and Ware, I encountered a fairly simple case study (pp 210-7) in which a longitudinal model specifies three random effects: (1) random intercepts for id, (2) random slopes for covariate1 (Age | id), and (3) random slopes for covariate2 (log(ht) | id). I've had no difficulty formulating lmer models with correlated random intercepts and slopes for either of the covariates individually but have not succeeded when I try to compose a model with correlated random intercepts and slopes for two covariates.
Following is code that works well with the individual covariates separately:
m1=lmer(LFEV1~Age + loght + InitAge + logbht + (1 + Age | id),data=fev,
na.action=na.omit, method="REML")
m2=lmer(LFEV1~Age + loght + InitAge + logbht+(1 + loght | id),data=fev,
na.action=na.omit, method="REML")
Maybe I am missing the point but wouldn't the model you are considering be written as lmer(LFEV1 ~ Age + loght + InitAge + logbht + (loght + Age|id), data = fev, na.action = na.omit, method = "REML") That provides correlated random effects for the intercept, the coefficient for loght and the coefficient for Age at each level of the id factor.
Thank you for taking the time to try to help me, Douglas. I had already
formulated the suggested model as model m3 shown below. Please note that id
is defined as "ordered" and all other variables are defined as "numeric".
Here are the models I've tried:
m1=lmer(LFEV1~Age+loght+InitAge+logbht+(1+Age|id),data=fev,
na.action=na.omit,
method="REML")
m2=lmer(LFEV1~Age+loght+InitAge+logbht+
(1+loght|id),data=fev,
na.action=na.omit,
method="REML")
m3=lmer(LFEV1~Age+loght+InitAge+logbht+
(Age+loght|id),
data=fev,
na.action=na.omit,
method="REML")
lmer handles models m1 and m2 with no difficulty (and the results agree
quite closely with SAS Proc Mixed returns). However, lmer generates the
following warning messages for m3 and lead me to wonder if I'd mispecified
the model:
1: Estimated variance-covariance for factor 'id' is singular
in: `LMEoptimize<-`(`*tmp*`, value = list(maxIter = 200L, tolerance =
1.49011611938477e-08,
2: nlminb returned message false convergence (8)
in: `LMEoptimize<-`(`*tmp*`, value = list(maxIter = 200L, tolerance =
1.49011611938477e-08,
Please note that when I run this model through SAS Proc Mixed, I get quite
different results for the random effects without apparent convergence
problems.
Following is the lmer summary of random effects for m3:
Linear mixed-effects model fit by REML
Formula: LFEV1 ~ Age + loght + InitAge + logbht + (Age + loght | id)
Data: fev
AIC BIC logLik MLdeviance REMLdeviance
-4511 -4449 2266 -4570 -4533
Random effects:
Groups Name Variance Std.Dev. Corr
id 3.1748e-03 0.0563455
7.4210e-06 0.0027241 0.064
9.4341e-03 0.0971292 0.064 1.000
Residual 3.9789e-03 0.0630788
number of obs: 1993, groups: id, 299
In retrospect, I wonder if I should attempt to add an override for default
convergence control values in lmer for m3.
I'll be glad to email you the dataset and programs directly if you'd like.
Respectfully,
Andy
-----Original Message-----
From: dmbates at gmail.com [mailto:dmbates at gmail.com] On Behalf Of Douglas
Bates
Sent: Wednesday, September 05, 2007 9:22 PM
To: ajbush at bellsouth.net
Cc: r-sig-mixed-models at r-project.org
Subject: Re: [R-sig-ME] Specifying random effects for multiple covariates
via lmer
On 9/5/07, Andy Bush <ajbush at bellsouth.net> wrote:
While working through the text "Applied Longitudinal Analysis" by Fitzmaurice, Laird and Ware, I encountered a fairly simple case study (pp 210-7) in which a longitudinal model specifies three random effects: (1) random intercepts for id, (2) random slopes for covariate1 (Age | id), and (3) random slopes for covariate2 (log(ht) | id). I've had no difficulty formulating lmer models with correlated random intercepts and slopes for either of the covariates individually but have not succeeded when I try to compose a model with correlated random intercepts and slopes for two covariates.
Following is code that works well with the individual covariates
separately:
m1=lmer(LFEV1~Age + loght + InitAge + logbht + (1 + Age | id),data=fev,
na.action=na.omit, method="REML")
m2=lmer(LFEV1~Age + loght + InitAge + logbht+(1 + loght | id),data=fev,
na.action=na.omit, method="REML")
Maybe I am missing the point but wouldn't the model you are considering be written as lmer(LFEV1 ~ Age + loght + InitAge + logbht + (loght + Age|id), data = fev, na.action = na.omit, method = "REML") That provides correlated random effects for the intercept, the coefficient for loght and the coefficient for Age at each level of the id factor.
On 9/6/07, Andy Bush <ajbush at bellsouth.net> wrote:
Thank you for taking the time to try to help me, Douglas. I had already
formulated the suggested model as model m3 shown below. Please note that id
is defined as "ordered" and all other variables are defined as "numeric".
Here are the models I've tried:
m1=lmer(LFEV1~Age+loght+InitAge+logbht+(1+Age|id),data=fev,
na.action=na.omit,
method="REML")
m2=lmer(LFEV1~Age+loght+InitAge+logbht+
(1+loght|id),data=fev,
na.action=na.omit,
method="REML")
m3=lmer(LFEV1~Age+loght+InitAge+logbht+
(Age+loght|id),
data=fev,
na.action=na.omit,
method="REML")
lmer handles models m1 and m2 with no difficulty (and the results agree
quite closely with SAS Proc Mixed returns). However, lmer generates the
following warning messages for m3 and lead me to wonder if I'd mispecified
the model:
1: Estimated variance-covariance for factor 'id' is singular
in: `LMEoptimize<-`(`*tmp*`, value = list(maxIter = 200L, tolerance =
1.49011611938477e-08,
2: nlminb returned message false convergence (8)
in: `LMEoptimize<-`(`*tmp*`, value = list(maxIter = 200L, tolerance =
1.49011611938477e-08,
Please note that when I run this model through SAS Proc Mixed, I get quite
different results for the random effects without apparent convergence
problems.
Thanks for checking further on this. I would appreciate it if you could email the data. One way to do this so that it retains all the attributes is to create an R Data save file save(fev, file = "fev.rda") and email that file. The representation in such a file is independent of the hardware and operating system. By the way, when you get such results it is a good idea to rerun the model fitting process with the "verbose" option set. In the currently released version of the lme4 package this is done with the rather wordy argument specification control = list(msVerbose = 1) In the development version of the lme4 package this specification still works or it can be shortened to verbose = 1
Following is the lmer summary of random effects for m3:
Linear mixed-effects model fit by REML
Formula: LFEV1 ~ Age + loght + InitAge + logbht + (Age + loght | id)
Data: fev
AIC BIC logLik MLdeviance REMLdeviance
-4511 -4449 2266 -4570 -4533
Random effects:
Groups Name Variance Std.Dev. Corr
id 3.1748e-03 0.0563455
7.4210e-06 0.0027241 0.064
9.4341e-03 0.0971292 0.064 1.000
Residual 3.9789e-03 0.0630788
number of obs: 1993, groups: id, 299
Notice that one of the correlations is effectively 1.00. This indicates a singular variance-covariance matrix for the random effects. The maximum likelihood estimates or the REML estimates can correspond to a singular matrix. In this case none of the variances are zero, it is a variance of a linear combination of the random effects that has been driven to zero. SAS PROC MIXED doesn't handle this situation well.
In retrospect, I wonder if I should attempt to add an override for default convergence control values in lmer for m3.
Typically that doesn't improve the situation. If the REML estimates are singular no amount of tweaking of the optimization procedure will improve the situation.
I'll be glad to email you the dataset and programs directly if you'd like.
I appreciate the offer and look forward to examining the data and models.
-----Original Message----- From: dmbates at gmail.com [mailto:dmbates at gmail.com] On Behalf Of Douglas Bates Sent: Wednesday, September 05, 2007 9:22 PM To: ajbush at bellsouth.net Cc: r-sig-mixed-models at r-project.org Subject: Re: [R-sig-ME] Specifying random effects for multiple covariates via lmer On 9/5/07, Andy Bush <ajbush at bellsouth.net> wrote:
While working through the text "Applied Longitudinal Analysis" by Fitzmaurice, Laird and Ware, I encountered a fairly simple case study (pp 210-7) in which a longitudinal model specifies three random effects: (1) random intercepts for id, (2) random slopes for covariate1 (Age | id), and (3) random slopes for covariate2 (log(ht) | id). I've had no difficulty formulating lmer models with correlated random intercepts and slopes for either of the covariates individually but have not succeeded when I try to compose a model with correlated random intercepts and slopes for two covariates.
Following is code that works well with the individual covariates
separately:
m1=lmer(LFEV1~Age + loght + InitAge + logbht + (1 + Age | id),data=fev,
na.action=na.omit, method="REML")
m2=lmer(LFEV1~Age + loght + InitAge + logbht+(1 + loght | id),data=fev,
na.action=na.omit, method="REML")
Maybe I am missing the point but wouldn't the model you are considering be written as lmer(LFEV1 ~ Age + loght + InitAge + logbht + (loght + Age|id), data = fev, na.action = na.omit, method = "REML") That provides correlated random effects for the intercept, the coefficient for loght and the coefficient for Age at each level of the id factor.
Dear Douglas, In frustration, I invoked lmer2 this morning and I'm pleased to be able to tell you that lmer2 copes well and quickly with the model having a random intercept and two random covariate slopes. I have not been able to get lmer to converge for the model on the same data. Andy -----Original Message----- From: dmbates at gmail.com [mailto:dmbates at gmail.com] On Behalf Of Douglas Bates Sent: Wednesday, September 05, 2007 9:22 PM To: ajbush at bellsouth.net Cc: r-sig-mixed-models at r-project.org Subject: Re: [R-sig-ME] Specifying random effects for multiple covariates via lmer
On 9/5/07, Andy Bush <ajbush at bellsouth.net> wrote:
While working through the text "Applied Longitudinal Analysis" by Fitzmaurice, Laird and Ware, I encountered a fairly simple case study
(pp
210-7) in which a longitudinal model specifies three random effects:
(1)
random intercepts for id, (2) random slopes for covariate1 (Age | id),
and
(3) random slopes for covariate2 (log(ht) | id). I've had no
difficulty
formulating lmer models with correlated random intercepts and slopes
for
either of the covariates individually but have not succeeded when I
try to
compose a model with correlated random intercepts and slopes for two covariates.
Following is code that works well with the individual covariates
separately:
m1=lmer(LFEV1~Age + loght + InitAge + logbht + (1 + Age |
id),data=fev,
na.action=na.omit, method="REML")
m2=lmer(LFEV1~Age + loght + InitAge + logbht+(1 + loght |
id),data=fev,
na.action=na.omit, method="REML")
Maybe I am missing the point but wouldn't the model you are considering be written as lmer(LFEV1 ~ Age + loght + InitAge + logbht + (loght + Age|id), data = fev, na.action = na.omit, method = "REML") That provides correlated random effects for the intercept, the coefficient for loght and the coefficient for Age at each level of the id factor.
On 9/6/07, Bush, Andrew J <abush at utmem.edu> wrote:
Dear Douglas,
In frustration, I invoked lmer2 this morning and I'm pleased to be able to tell you that lmer2 copes well and quickly with the model having a random intercept and two random covariate slopes. I have not been able to get lmer to converge for the model on the same data.
Thanks for the information. I expect to remove the confusion between lmer and lmer2 in the near future. The development version of the lme4 package has an lmer function that is close to the current lmer2 in design. It should exhibit the same convergence behavior and be slightly faster on models fit to large data sets than is the current lmer2. This version has been in development for longer than I had expected. I still have a few "infelicities" to resolve in the Laplace method for generalized linear mixed models before I make test versions available. I would be interested in the data set if you would be willing to provide it. I could perhaps incorporate it in the lme4 package so others would have access to it.
-----Original Message----- From: dmbates at gmail.com [mailto:dmbates at gmail.com] On Behalf Of Douglas Bates Sent: Wednesday, September 05, 2007 9:22 PM To: ajbush at bellsouth.net Cc: r-sig-mixed-models at r-project.org Subject: Re: [R-sig-ME] Specifying random effects for multiple covariates via lmer On 9/5/07, Andy Bush <ajbush at bellsouth.net> wrote:
While working through the text "Applied Longitudinal Analysis" by Fitzmaurice, Laird and Ware, I encountered a fairly simple case study
(pp
210-7) in which a longitudinal model specifies three random effects:
(1)
random intercepts for id, (2) random slopes for covariate1 (Age | id),
and
(3) random slopes for covariate2 (log(ht) | id). I've had no
difficulty
formulating lmer models with correlated random intercepts and slopes
for
either of the covariates individually but have not succeeded when I
try to
compose a model with correlated random intercepts and slopes for two covariates.
Following is code that works well with the individual covariates
separately:
m1=lmer(LFEV1~Age + loght + InitAge + logbht + (1 + Age |
id),data=fev,
na.action=na.omit, method="REML")
m2=lmer(LFEV1~Age + loght + InitAge + logbht+(1 + loght |
id),data=fev,
na.action=na.omit, method="REML")
Maybe I am missing the point but wouldn't the model you are considering be written as lmer(LFEV1 ~ Age + loght + InitAge + logbht + (loght + Age|id), data = fev, na.action = na.omit, method = "REML") That provides correlated random effects for the intercept, the coefficient for loght and the coefficient for Age at each level of the id factor.
5 days later
"DB" == Douglas Bates <bates at stat.wisc.edu>
on Thu, 6 Sep 2007 11:17:17 -0500 writes:
DB> On 9/6/07, Bush, Andrew J <abush at utmem.edu> wrote:
>> Dear Douglas,
>> In frustration, I invoked lmer2 this morning and I'm pleased to be able
>> to tell you that lmer2 copes well and quickly with the model having a
>> random intercept and two random covariate slopes. I have not been able
>> to get lmer to converge for the model on the same data.
DB> Thanks for the information.
DB> I expect to remove the confusion between lmer and lmer2 in the near
DB> future. The development version of the lme4 package has an lmer
DB> function that is close to the current lmer2 in design. It should
DB> exhibit the same convergence behavior and be slightly faster on models
DB> fit to large data sets than is the current lmer2.
DB> This version has been in development for longer than I had expected.
DB> I still have a few "infelicities" to resolve in the Laplace method for
DB> generalized linear mixed models before I make test versions available.
DB> I would be interested in the data set if you would be willing to
DB> provide it. I could perhaps incorporate it in the lme4 package so
DB> others would have access to it.
Yes, indeed.
The example might be particularly interesting as test case, not
only because some software implementations "converge" with
singular covariance matrix, but also because it
differs from other examples in having "many" fixed effects and
just one level random effects.
Martin
>> -----Original Message-----
>> From: dmbates at gmail.com [mailto:dmbates at gmail.com] On Behalf Of Douglas
>> Bates
>> Sent: Wednesday, September 05, 2007 9:22 PM
>> To: ajbush at bellsouth.net
>> Cc: r-sig-mixed-models at r-project.org
>> Subject: Re: [R-sig-ME] Specifying random effects for multiple
>> covariates via lmer
>>
>> On 9/5/07, Andy Bush <ajbush at bellsouth.net> wrote:
>> > While working through the text "Applied Longitudinal Analysis" by
>> > Fitzmaurice, Laird and Ware, I encountered a fairly simple case study
>> (pp
>> > 210-7) in which a longitudinal model specifies three random effects:
>> (1)
>> > random intercepts for id, (2) random slopes for covariate1 (Age | id),
>> and
>> > (3) random slopes for covariate2 (log(ht) | id). I've had no
>> difficulty
>> > formulating lmer models with correlated random intercepts and slopes
>> for
>> > either of the covariates individually but have not succeeded when I
>> try to
>> > compose a model with correlated random intercepts and slopes for two
>> > covariates.
>>
>> > Following is code that works well with the individual covariates
>> separately:
>>
>> > m1=lmer(LFEV1~Age + loght + InitAge + logbht + (1 + Age |
>> id),data=fev,
>> > na.action=na.omit, method="REML")
>>
>> > m2=lmer(LFEV1~Age + loght + InitAge + logbht+(1 + loght |
>> id),data=fev,
>> > na.action=na.omit, method="REML")
>>
>> Maybe I am missing the point but wouldn't the model you are
>> considering be written as
>>
>> lmer(LFEV1 ~ Age + loght + InitAge + logbht + (loght + Age|id), data =
>> fev, na.action = na.omit, method = "REML")
>>
>> That provides correlated random effects for the intercept, the
>> coefficient for loght and the coefficient for Age at each level of the
>> id factor.
>>
DB> _______________________________________________
DB> R-sig-mixed-models at r-project.org mailing list
DB> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Quoting Martin Maechler <maechler at stat.math.ethz.ch>:
"DB" == Douglas Bates <bates at stat.wisc.edu>
on Thu, 6 Sep 2007 11:17:17 -0500 writes:
DB> On 9/6/07, Bush, Andrew J <abush at utmem.edu> wrote:
>> Dear Douglas,
>> In frustration, I invoked lmer2 this morning and I'm pleased
to be able
>> to tell you that lmer2 copes well and quickly with the model having a
>> random intercept and two random covariate slopes. I have not
been able
>> to get lmer to converge for the model on the same data.
DB> Thanks for the information.
DB> I expect to remove the confusion between lmer and lmer2 in the near
DB> future. The development version of the lme4 package has an lmer
DB> function that is close to the current lmer2 in design. It should
DB> exhibit the same convergence behavior and be slightly faster
on models
DB> fit to large data sets than is the current lmer2.
DB> This version has been in development for longer than I had expected.
DB> I still have a few "infelicities" to resolve in the Laplace
method for
DB> generalized linear mixed models before I make test versions
available.
DB> I would be interested in the data set if you would be willing to
DB> provide it. I could perhaps incorporate it in the lme4 package so
DB> others would have access to it.
Yes, indeed.
The example might be particularly interesting as test case, not
only because some software implementations "converge" with
singular covariance matrix, but also because it
differs from other examples in having "many" fixed effects and
just one level random effects.
The data set in question, and, I belive, most others from Fitzmaurice, Laird and Ware's (2004) book on longitudinal data analysis, is available along with accompanying SAS programs at http://biosun1.harvard.edu/~fitzmaur/ala/ In particular, the data used above is here http://biosun1.harvard.edu/~fitzmaur/ala/fev1.txt and the SAS code is here http://biosun1.harvard.edu/~fitzmaur/ala/prog8_8.html HTH, Henric
Martin
>> -----Original Message-----
>> From: dmbates at gmail.com [mailto:dmbates at gmail.com] On Behalf
Of Douglas
>> Bates
>> Sent: Wednesday, September 05, 2007 9:22 PM
>> To: ajbush at bellsouth.net
>> Cc: r-sig-mixed-models at r-project.org
>> Subject: Re: [R-sig-ME] Specifying random effects for multiple
>> covariates via lmer
>>
>> On 9/5/07, Andy Bush <ajbush at bellsouth.net> wrote:
>> > While working through the text "Applied Longitudinal Analysis" by
>> > Fitzmaurice, Laird and Ware, I encountered a fairly simple
case study
>> (pp
>> > 210-7) in which a longitudinal model specifies three random effects:
>> (1)
>> > random intercepts for id, (2) random slopes for covariate1
(Age | id),
>> and
>> > (3) random slopes for covariate2 (log(ht) | id). I've had no
>> difficulty
>> > formulating lmer models with correlated random intercepts and slopes
>> for
>> > either of the covariates individually but have not succeeded when I
>> try to
>> > compose a model with correlated random intercepts and slopes for two
>> > covariates.
>>
>> > Following is code that works well with the individual covariates
>> separately:
>>
>> > m1=lmer(LFEV1~Age + loght + InitAge + logbht + (1 + Age |
>> id),data=fev,
>> > na.action=na.omit, method="REML")
>>
>> > m2=lmer(LFEV1~Age + loght + InitAge + logbht+(1 + loght |
>> id),data=fev,
>> > na.action=na.omit, method="REML")
>>
>> Maybe I am missing the point but wouldn't the model you are
>> considering be written as
>>
>> lmer(LFEV1 ~ Age + loght + InitAge + logbht + (loght + Age|id), data =
>> fev, na.action = na.omit, method = "REML")
>>
>> That provides correlated random effects for the intercept, the
>> coefficient for loght and the coefficient for Age at each level of the
>> id factor.
>>
DB> _______________________________________________
DB> R-sig-mixed-models at r-project.org mailing list
DB> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20070913/8c9fab35/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20070913/1f22de28/attachment.pl>
On Thu, Sep 13, 2007 at 09:51:17AM +0200, Henric Nilsson (Private) wrote:
The data set in question, and, I belive, most others from Fitzmaurice, Laird and Ware's (2004) book on longitudinal data analysis, is
Which, I would like to add is a great book. As part of a review for Statistics in Medicine I asked Fitzmaurice to count the occurrences of "For example," and "In other words," ... it was 300 and 400 times, respectively. I heartily recommend it as an introductory text to the area. Andrew
available along with accompanying SAS programs at http://biosun1.harvard.edu/~fitzmaur/ala/ In particular, the data used above is here http://biosun1.harvard.edu/~fitzmaur/ala/fev1.txt and the SAS code is here http://biosun1.harvard.edu/~fitzmaur/ala/prog8_8.html HTH, Henric
Andrew Robinson Department of Mathematics and Statistics Tel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/