[R] nested model: lme, aov and LSMeans

Douglas Bates bates at stat.wisc.edu
Wed Feb 14 15:26:45 CET 2007


On 2/13/07, shirley zhang <shirley0818 at gmail.com> wrote:
> I'm working with a nested model (mixed).
>
> I have four factors: Patients, Tissue, sex, and tissue_stage.
>
> Totally I have 10 patients, for each patient, there are 2 tissues
> (Cancer vs. Normal).
>
> I think Tissue and sex are fixed. Patient is nested in sex,Tissue is
> nested in patient,  and tissue_stage is nested in Tissue.
>
> I tried aov and lme as the following,
>
> > aov(gene ~ tissue + gender + patients%in%gender + stage%in%tissue
> >lme(gene ~ tissue + gender, random = list(patients = ~1 , stage = ~ 1))

I think it is easier to specify the model for the lmer function in the
lme4 package

lmer(gene ~ tissue + gender + (1|patient:gender) +
(1|patient:gender:tissue:tissue_stage))

It sounds like you have coded the factors with implicit nesting.  That
is, even though you have 20 different tissue samples (I believe) the
tissue factor takes only two levels.  I don't know if you have 10
distinct levels of patient or if, for example, there is a male patient
1 and a female patient 1.  If the latter case then you must use the
grouping factor patient:gender to be able to distinguish the
observations on the male patient 1 from those on the female patient 1.
 Even if you have 10 distinct levels of the patient factor it does no
harm to specify the grouping as patient:gender - it's just a longer
expression to type.

The basic rule is tha the number of distinct levels in the grouping
factor must correspond to the number of levels of the corresponding
experimental unit.  (I know, that seems obvious but it doesn't always
work out that way.)  This is why the number of levels of the different
grouping factors are reported following the estimates of the variance
components in the summary of the fitted model.  You should always
check that to see that it makes sense.

>
>
> I got results from aov, but I got error message from lme which is
> false convergence (8). so I could not compare the results of aov with
> lme.
>
> Could anybody tell me whether I use the correct command? How can I get
> LSMeans for Cancer vs. Normal in R ( I know it is easy in SAS)?
>
> Thanks,
>
> Shirley
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list