[R] Random and fixed effect model with a covariate

Sophie Alice Octavia Armitage SAOArmitage at bi.ku.dk
Tue Jan 29 17:04:49 CET 2008

Dear All,

I wonder if anyone can please offer any advice on a model including 2 fixed effects and 1 random effect, as well as a covariate? 

The experimental design is as follows:
I have a two by two factor design, where the two factors, Age (A) and Group size (G), both have 2 levels (old or young, and 1 or 3 respectively), and I am interested in the effect of these factors upon a continuous Response variable (R).

The data is from social insects, so the above design is repeated for several colonies. I think that Colony (C) should be a random factor, as they were taken from a larger pool of available colonies. Identification number (I) is different for each individual.

Furthermore, I have a covariate, Mass (M), which could have an effect upon R.

Do you know which of the below (if any) would be the most appropriate model please?


or is it necessary to state that A and G are factors as below:

model<-lme(R~as.factor(A)*as.factor(G)*M,random= ~1|C/I)
model<-lme(R~as.factor(A)*as.factor(G)+M,random= ~1|C/I)

Do you also please have any advice upon the effect it would have to change the order in which the factors and covariate are placed in the model? When I tried moving them around in the above models it changed the test statistics slightly. 

Many thanks in advance for any help you can give, it’s very much appreciated.

Sophie Armitage

More information about the R-help mailing list