Re: [R] lme syntax for P&B examples

From: Prof Brian Ripley <>
Date: Thu 09 Feb 2006 - 18:29:43 EST

On Thu, 9 Feb 2006, Paul Cossens wrote:

> Hi Harold,
> Thanks for your reply. I had already looked at all the reading material
> you suggested but updated to the latest Matrix
> as recommneded then spent all day trying to figure out what is
> happening.
> I worked through the problems and give my workings below that others may
> find useful.
> (My notation is to use lme> to show lme commands and lmer> to show lmer
> commands.
> I worked on two sessions in parallel. My comments are preceded by double
> hashes '##' and
> questions '##??'. I haven't included the datasets.)
> I have a couple of comments and outstanding issues:
> 1. In the Pixel data set and formulas I think the formulas are printed
> incorrectly in the
> book as some use 'I(day^2)' while others use just 'day^2'. I have used
> 'I(day^2)'. I'm not sure why the I() function is used. In the fm4Pixel
> example below the answers don't match up exactly but are close.

That is an R/S difference (documented in the FAQ). In R day^2 is the same as day in a formula.

The book is about S, not R (as its title tells you).

> The lme example is
> fm1Pixel<-lme(pixel~day+I(day^2),data=Pixel,random = list(Dog=~day
> ,Side=~1))
> fm5Pixel <- update(fm1Pixel,pixel ~ day + I(day^2) + Side)
> which I have converted to lmer:
> fm4Pixel <- lmer(pixel ~ day + I(day^2) +Side +(day|Dog), data = Pixel)
> The t-values for Side are close (sse below) but different enough to
> wonder if I am still doing something wrong?
> 2. To me the specification description in the R-News article is
> confusing as it seems
> to suggest that nesting does not need to be completely specified if the
> groupings and nestings are clear in data set.
> Prof Bates article in R news vol 5/1 P 30 states "It happens in this
> case that the grouping factors 'id' and 'sch' are not nested but if they
> were nested there would be no change in the model specification"
> If the lme formula is
> fm1Oxide<-lme(Thickness~1,Oxide)
> I have found the formula lmer parlance should be:
> 'fm1Oxide<-lmer(Thickness~ (1|Lot)+(1|Lot:Wafer),data=Oxide)'
> not 'fm1Oxide<-lmer(Thickness~ (1|Lot)+(1|Wafer),data=Oxide)'
> as the article reads to me.
> In other words you always need to explicitly specify nesting levels.

You cannot deduce `always' from one example. It depends if (in your case) the Wafers are numbered uniquely or the same in each Lot. This comes up frequently with muiti-stratum aov and lme.

Notice that Dr Bates carefully said `It happens in this case', so he did not generalize from a single example.


Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Thu Feb 09 23:25:36 2006

This archive was generated by hypermail 2.1.8 : Sat 11 Feb 2006 - 01:59:33 EST