[R-sig-ME] lme - nested - One fixed effect and another within thatas random effect

Douglas Bates bates at stat.wisc.edu
Tue Nov 27 16:00:59 CET 2007


On Nov 27, 2007 8:43 AM, Doran, Harold <HDoran at air.org> wrote:
> What do you mean by not working? Your lme and lmer code seem to be
> equivalent.

Not really.  Supplier:Batch is the batch grouping factor without the
implicit nesting.  That is, it has a different level for each
different batch (which seems to me to be the only sensible way to
define such a factor but, in the old days, people seemed to think it
was important to specify nesting implicitly).  The expression
Supplier/Batch implies two random effects, one for Supplier and one
for Supplier:Batch.

The simple way out is to define

process$realBatch <- with(process, Supplier:Batch)

and fit the lme model with random = ~ 1|realBatch

> > -----Original Message-----
> > From: r-sig-mixed-models-bounces at r-project.org
> > [mailto:r-sig-mixed-models-bounces at r-project.org] On Behalf Of Divaker
> > Sent: Monday, November 26, 2007 9:26 PM
> > To: r-sig-mixed-models at r-project.org
> > Subject: [R-sig-ME] lme - nested - One fixed effect and
> > another within thatas random effect
> >
> > Dear R mixed model Users and Dr. Bates,
> >
> > I am trying to work out a problem given in Nested design -
> > Design of Experiments by  Montgomery -  p.561 using lme It is
> > a mixed model with Supplier as fixed effect and batches
> > within the supplier as random effects.
> >
> > When I tried my hands on lmer instead of lme, I get what is
> > required  as below.
> >
> > > proclme=lmer(Purity~Supplier+(1|Supplier:Batch),process)
> > > print(summary(proclme))
> > Linear mixed-effects model fit by REML
> > Formula: Purity ~ Supplier + (1 | Supplier:Batch)
> >    Data: process
> >    AIC   BIC logLik MLdeviance REMLdeviance
> >  150.8 157.2 -71.42      146.9        142.8
> > Random effects:
> >  Groups         Name        Variance Std.Dev.
> >  Supplier:Batch (Intercept) 1.7162   1.3100   Here we have
> > the variance of random effect exactly as in the book
> >  Residual                   2.6368   1.6238
> > number of obs: 36, groups: Supplier:Batch, 12
> >
> > Fixed effects:
> >             Estimate Std. Error t value
> > (Intercept)  -0.4167     0.8055 -0.5173
> > SupplierT2    0.7500     1.1391  0.6584
> > SupplierT3    1.5833     1.1391  1.3900
> >
> > Correlation of Fixed Effects:
> >            (Intr) SpplT2
> > SupplierT2 -0.707
> > SupplierT3 -0.707  0.500
> >
> > But using lme, it is not working. Is there any way out.lme is
> > not accepting the format random=~1|Supplier : Batch I am more
> > comfortable using lme since the supporting docs are exaustive
> > and we have access to many support functions for lme
> >
> > This code is not appropriate and also not working
> > library(nlme)
> > proclme=lme(Purity~Supplier,random = ~1|Supplier/Batch,process)
> > summary(proclme)
> > VarCorr(proclme)
> >
> >
> > Divaker
> >
> > Dr. C. Divaker Durairaj, ME, Ph.D
> > Professor, Farm Machinery
> > Agricultural Machinery Research Centre
> > Tamil Nadu Agricultural University
> > Coimbatore 641003, India
> > Ph: 91-422-6611204
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-mixed-models at r-project.org mailing list
> > 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
>




More information about the R-sig-mixed-models mailing list