[R-sig-ME] Random or Fixed effects appropriate?
njbisaac at googlemail.com
Tue Apr 8 17:39:08 CEST 2008
I would be grateful for some advice to help me fit the right model.
Specifically, I can't work out whether it's more appropriate to get
the answer I need from a random slopes model or by adding a fixed
My dataset has one continuous normally-distributed fixed effect and
four random effects that are nested (in fact, it is a taxonomy). For
simplicity, I've removed the variable names, so the dataset has the
y ~ x | A/B/C/D
My hypothesis is that the relationship between x and y varies at
different levels of the taxonomy, but I have no a priori expectation
of which level would be most appropriate (i.e one or more of A, B, C
or D). The structure is very unbalanced, so I fit a series of mixed
lmer( y ~ x + (1|A) + (1|B) + (1|C) + (1|D) )
lmer( y ~ x + (1|A) + (1|B) + (1|C) + (x|D) )
lmer( y ~ x + (x|A) + (x|B) + (x|C) + (x|D) )
and compared them using AIC. So far so good, I thought.
As the research has progressed, I have become interested in the actual
values of the slope between x and y at each level of the random
effects. So I extracted them:
coef( lmer( y ~ x + (1|A) + (1|B) + (x|C) + (1|D) ) )
I can plot these out and compare them with other attributes of random
effect C. But I'm treating the random effects as if they were
parameters, which feels like cheating. I've no idea if there is a
precedent for this: a quick look at the R-SIG-ME archive reveals that
folks do use coef(), but the context is rather different.
So I've also tried adding x:C as an interaction term in a fixed effect model:
lmer( y ~ x + (1|A) + (1|B) + (1|C) + (1|D) + C + x:C) #error:
Downdated X'X is not positive definite, 82
lmer( y ~ x + (1|A) + (1|B) + (1|C) + (1|D) + x:C) #gives sensible results
Parameter values for x:C are very close to the random effects. Some
extreme values have small samples and correspondingly large standard
errors. This is one reason why I like using the random effects:
shrinkage effectively gives them equal weight. But is this reasonable
I think this question reflects some flaw in my understanding, for
which I apologise. Any insights would be gratefully received.
Best wishes, Nick
More information about the R-sig-mixed-models