Skip to content

Factor level comparisons in lme

2 messages · Martin Biuw, Douglas Bates

#
Martin Biuw <emb7 at st-andrews.ac.uk> writes:
Did you mean 

lme(y ~ x * Sex * Year, random= ~ x|subject)

The random argument should be a formula or a list.
This isn't really an lme question - it is a question about the
parameterization used in the model matrix for a linear model formula.

I'm not sure what you mean by "allow comparisons to the overall
mean".  You may find that setting

 options(contrasts=c('contr.sum', 'contr.poly'))

does what you want or what you want to do may be impossible.  With two
levels of Sex and, say, 4 levels of year, the number of degrees of
freedom in the crossed factors plus intercept is
  1(constant) + 1(Sex) + 3(Year) + 3(Sex * Year) = 8
If you want to get separate means for each level of Sex and Year and
Sex*Year you would need 
  2(Sex) + 4(Year) + 8(Sex*Year) = 14 
degrees of freedom.