[R-sig-ME] Mixed-effects models: question about the syntax to include interactions

Anaid Diaz syadp at yahoo.com.mx
Tue Mar 25 17:23:07 CET 2008

Hello everyone,

I would like to as for advice on the use of “lmer”
(package ‘lme4’) and writing the proper syntax to best
describe my data using a mixed-effects model.

I have just started using these models, and although I
have read some good examples (Extending the Linear
Model with R, Faraway 2005; and the R book, Crawley
2007), I am still not sure what is the best syntax to
test my hypothesis.

Thanks in advance for reading me.

Briefly, I describe the data and the situation:

I want to describe the age-specific fecundity of the
ith individual from the jth replicate (or line) from
the kth strain.


Categorical factors:

A[a] = Age (1,2,3
n=8) #Because the fecundity is not
linear, I decided to include it in the model as a
s[k] =strain (A and B, n=2) # for the moment two, but
it’s likely to increase as the work progresses
l[j]   = line (1,2,..n=10)
i[i]   = Ind(1,2

(Note: I use capital letters for fixed factors and low
case for random effects)

Because the experimental design, the data follows a
hierarchical structure: where the ith individual is
nested within the jth line, and line within the kth

Continuous (response) variable:
Y =Age-specific fecundity (362 observations)


Because I was (I am still) not sure of how to include
all the variables in a single model, I started by
splitting up the data and assessing which is the best
model for each strain, therefore the “Simplest” model
for each strain is:

Linear model.

Y[aij] = A[a] + error[aij]

R code:

m1 <- lm(fecudnity ~ Age)

Reduced mixed-effect model:

Y[aij] = A[a] + l[j] + i[i] + error[aij]

R code:

m2 <- lmer(fecudnity ~ Age + (1 | line/ind),

And a “Full mixed-effects model” model (looking for
interactions between Age and line/ind)

Y[aij] = A[a] + A[a]*l[j] + A[a]*i[i] + error[aij]

R code:

m3 <- lmer(fecudnity ~ Age + (Age | line/ind),

I have used Likelihood test ratio (LTR) to compare
between models, and I have found that for strain A the
best model is m3 (X^2 [36 d.f] =164.8, p-value=
4.73e-13), whereas for strain B, the best one is m1
(X^2 [2 d.f] =1.47, p-value= 0.473). Therefore, I
interpret these results as follow:

-	The variance between individuals in strain A is
large, and it is best described when I include
information about the line where the individuals come
from. Moreover, there is a significant interaction
between age and line/ind. Thus, some individuals have
higher fecundity at later ages compared to others.

-	The variance between individuals in strain B is low;
therefore the variance between ind/lines and
interactions can be ignored. 

These results, on their own, are quite interesting,
but I would like to have a model where I include both
strains (and still can make some interpretations)

My first guess is

m4 <- lmer(fecudnity ~ Age + (1 | strain/line/ind),
m5 <- lmer(fecudnity ~ Age + (Age | strain/line/ind),

Using LTR, I find that m5 describes better the data
(X^2 [105 d.f] = 347.15, p-value  < 2.2 e-16), but I
feel like I cannot say much of which strain has more
individual variance (or perhaps I am wrong and not
looking in the right place).

Then I though about using strain as a fixed factor,
because I am now interested in the differences between

m6 <- lmer(fecudnity ~ Age * Strain +  (Age
|strain/line/ind), method=”ML”)

or perhaps include it in the random interaction?

m7 <- lmer(fecudnity ~ Age +  (Age * Strain
|strain/line/ind), method=”ML”)

I have to be honest, at this point, I am just not sure
of how to write the model to describe the age-specific
fecundity and test the hypothesis of whether one
strain shows more variance between individuals and
lines or not. I hope some one could give some advice.

Thanks in advance

Anaid Diaz

~~~~~~~~~~~ ~ ~~~ ~ ~   ~   ~  ~   ~  ~
S.Anaid Diaz
Rm 303, Graham Kerr Bldg
Theoretical Ecology Group
Division of Environmental & Evolutionary Biology
University of Glasgow
Glasgow G12 8QQ

tel: 0141 330 2430
fax: 0141 330 5971


¡Capacidad ilimitada de almacenamiento en tu correo!
No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:

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