Skip to main content
2 of 2
added 495 characters in body
Hong Ooi
  • 8.3k
  • 3
  • 34
  • 59

Mixed model with 1 observation per level

I'm fitting a random effects model with glmer to some business data. The aim is to analyse sales performance by distributor, taking into account regional variation. I have the following variables:

  • distcode: distributor ID, with about 800 levels
  • region: top-level geographical ID (north, south, east, west)
  • zone: mid-level geography nested within region, about 30 levels in all
  • territory: low-level geography nested within zone, about 150 levels

Each distributor operates in only one territory. The tricky part is that this is summarised data, with one data point per distributor. So I have 800 data points and I'm trying to fit (at least) 800 parameters albeit in a regularised fashion.

I've fitted a model as follows:

glmer(ninv ~ 1 + (1|region/zone/territory) + (1|distcode), family=poisson)

This runs without a problem, although it does print a note:

Number of levels of a grouping factor for the random effects is equal to n, the number of observations

Is this a sensible thing to do? I get finite estimates of all the coefficients, and the AIC also isn't unreasonable. If I try a poisson GLMM with the identity link, the AIC is much worse so the log link is at least a good starting point.

If I plot the fitted values vs the response, I get what is essentially a perfect fit, which I guess is because I have one data point per distributor. Is that reasonable, or am I doing something completely silly?

This is using data for one month. I can get data for multiple months and get some replication that way, but I'd have to add new terms for month-to-month variation and possible interactions, correct?


ETA: I ran the above model again, but without a family argument (so just a gaussian LMM rather than a GLMM). Now lmer gave me the following error:

Error in (function (fr, FL, start, REML, verbose) : Number of levels of a grouping factor for the random effects must be less than the number of observations

So I'd guess that I'm not doing something sensible, as changing the family shouldn't have an effect. But the question now is, why did it work in the first place?

Hong Ooi
  • 8.3k
  • 3
  • 34
  • 59