Paul: It is a little difficult to understand what you are trying to translate since you do not show what the model would look like using lme. If you show lme, then it is easy to translate into lmer syntax. A few thoughts, first, use lmer in the Matrix package and not in lme4. Second, see the Bates article in R news at the link below for dealing with nesting structures. Last, a colleague and I have a paper in press showing how to fit models using lme which we submitted a year or so ago. Since lme has evolved to lmer, we created an appendix that translates all of our lme models to the lmer syntax so readers can see equivalences. I am happy to send this to you (or others) upon request. http://cran.r-project.org/doc/Rnews/Rnews_2005-1.pdf Harold -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Paul Cossens Sent: Wednesday, February 08, 2006 12:08 AM To: r-help at stat.math.ethz.ch Subject: [R] lme syntax for P&B examples Hi helpeRs, I've been working through some examples in Pinhiero & Bates( 2000) trying to understand how to translate to the new Lme4 syntax but without much luck. Below is what I think I should do, but either the answers don't come out the same or I get errors. In the Oxide problems I'm particularly interested in obtaining the levels coeficients but this options no longer seems to be available in lme4. How can levels infor be obtained in lme4? If someone can recreate the examples below in lme4 syntax so I can follow what is happening in the text I'd be grateful. Cheers Paul Cossens #Pixel # P&B(2000) p40-45 Pixel<-read.csv("Pixel.csv",header=TRUE); Pixel$Side<-as.factor(Pixel$Side) Pixel$Dog<-as.factor(Pixel$Dog) (fm1Pixel <- lmer(pixel ~ day + I(day^2) +(day|Dog)+(1|Side), data = Pixel)) (fm2Pixel <- lmer(pixel ~ day + I(day^2) +(day|Dog), data = Pixel)) (fm3Pixel <- lmer(pixel ~ day + I(day^2) +(1|Dog:Side), data = Pixel)) or should I do it this way? Pixel$DS<-with(Pixel,Dog:Side)[drop=TRUE] (fm3Pixel <- lmer(pixel ~ day + I(day^2) +(1|DS), data = Pixel)) (fm4Pixel <- lmer(pixel ~ day + I(day^2) +Side , data = Pixel)) #Oxide # P&B(2000) p167-170 Oxide<-read.csv("Oxide.csv",header=TRUE); Oxide$Source<-as.factor(Oxide$Source) Oxide$Lot<-as.factor(Oxide$Lot) Oxide$Wafer<-as.factor(Oxide$Wafer) Oxide$Site<-as.factor(Oxide$Site) fm1Oxide<-lmer(Thickness~ (1|Lot)+(1|Lot:Wafer),data=Oxide) ) (fm2Oxide<-lmer(Thickness~ (1|Lot),data=Oxide) ) coef(fm1Oxide) ______________________________________________ R-help at 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
lme syntax for P&B examples
2 messages · Doran, Harold, Martin Maechler
1 day later
"HaroldD" == Doran, Harold <HDoran at air.org>
on Wed, 8 Feb 2006 08:01:03 -0500 writes:
HaroldD> ................
HaroldD> A few thoughts, first, use lmer in the Matrix
HaroldD> package and not in lme4.
Well, that's potentially misleading advice: If both lme4 and
Matrix are (more or less) current, it is actually better to call
library(lme4) if you want to use lmer() .
A more extensive advice + explanation :
- "lme4" is the package you should use when using lmer().
Using "Matrix" *instead* works as well *currently*
(and yes, *currently* lmer is in the Matrix namespace).
- At the moment, "lme4" is an almost empty wrapper around using
package "Matrix", since the C code for lmer() needs to be
able to call C code inside "Matrix" and that is not yet
portably possible.
For that reason, everything for lmer() is currently inside
"Matrix", but that should change when R will have the
infrastructure for R packages to export their C API such that
other R packages can reliably use that C API.
HaroldD> ................
HaroldD> Last, a colleague and I have a paper in press
HaroldD> showing how to fit models using lme which we
HaroldD> submitted a year or so ago.
HaroldD> Since lme has evolved to lmer, we created an
HaroldD> appendix that translates all of our lme models to
HaroldD> the lmer syntax so readers can see equivalences. I
HaroldD> am happy to send this to you (or others) upon request.
That sounds quite interesting; I'll be glad to receive it as
well.
Martin Maechler, ETH Zurich
HaroldD> http://cran.r-project.org/doc/Rnews/Rnews_2005-1.pdf
HaroldD> Harold