Skip to content

empty cell

3 messages · Maria Eva Gongora, Douglas Bates, Ben Bolker

#
On Fri, Aug 29, 2008 at 1:07 PM, Maria Eva Gongora
<mariaevagongora at hotmail.com> wrote:
I regret that we won't be able to help without more information.  As
it says at the bottom of all the messages to the R-help mailing list

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
Maria Eva Gongora wrote:
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.
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