[R] Within-subject factors in lme

lorenz.gygax at art.admin.ch lorenz.gygax at art.admin.ch
Tue Jan 16 07:31:40 CET 2007

> Thanks for your suggestion. I guess the model you are fitting here
> has only a single random effect term, namely subject. If the effect
> of A depends on S, one needs to include an additional random effects
> term for the S:A interaction.

It is not quite clear what you are after, but the 'if' sounds as you would like to include interactions between your fixed and random effects? This is done in the following way:

lme (y ~ A + B, random= ~ A | S )
lme (y ~ A + B, random= ~ B | S )
lme (y ~ A + B, random= ~ A + B | S )

with redard to discussions on degrees of freedom (and thus testing in mixed-effects models) you may also want to refer to:

I hope this helps.
Regards, Lorenz Gygax
Swiss Federal Veterinary Office
Centre for proper housing of ruminants and pigs
Agroscope Reckenholz-Tänikon Research Station ART

More information about the R-help mailing list