[R-sig-ME] empty cell
Ben Bolker
bolker at zoology.ufl.edu
Fri Aug 29 21:51:02 CEST 2008
Maria Eva Gongora wrote:
> I am using mixed effect models (library lmer) to evaluate factors that
influence the catch rate of hake (set by set) in a fishery. I have some
empty cells when I include some of the interactions between the fixed
factors (e.g. year:area) and interactions between fixed and random effects
(e.g. year:vessel, where vessel is a random effect) . While empty cell were
not the problem when all factors were treated as fixed using lm or glm,
the estimation failed when I used lme4 and treated some of the factors
(the vessel id) as random.
> María Eva Góngora
> ______________________________________________
I suspect that the problem is the empty fixed interactions,
rather than the empty random effects levels (interactions
between fixed and random effects are random by definition).
When the fixed effects are this badly unbalanced,
lm and glm just go ahead and spit out NA for the
unestimable parameters, whereas lme4 is a little more
finicky.
r = runif(200)
d2 = cbind(expand.grid(year=factor(1:2),site=factor(1:2),
fac3=factor(1:2),rep=1:25),val=r,
val2=rpois(200,exp(r)))
## unbalance the data
d2 = subset(d2,!(site==2 & year==2))
lm(val~site*year,data=d2)
glm(val2~site*year,family="poisson",data=d2)
library(lme4)
lmer(val~site*year+(1|fac3),data=d2) ## fails
lmer(val~site+year+(1|fac3),data=d2) ## remove interaction -- succeeds
lmer(val~site+(year|fac3),data=d2) ## treating year as random works too
That said, it would be good to provide more detail as Doug Bates
suggests -- sometimes we're not very good at guessing what you mean ...
good luck
Ben Bolker
More information about the R-sig-mixed-models
mailing list