I understand that you would consider multilevel or hierarchical linear mixed effects model with your data are nested with multiple level and be grouped. However, I assume that the observation will belong to single group in the nested data.

However, if the there is a portion of observations would belong to multiple groups. But in general the data are nested with specific level. Can I consider the mixed effect model to control the unobserved effect from different level? Or I can only add two dummy variable as fixed effect from two different level and ignore the impact from the higher level?

  • $\begingroup$ It would help if you gave a bit more detail on what the observations and groups are, and how an observation can be in more than one group. There are different ways this can happen, and the way to model it would differ. $\endgroup$ May 17 at 5:55
  • $\begingroup$ For example, patients are treated by different physicians in hospitals. Patients may went to different hospitals to receive treatments and physicians could work at different hospitals. Though, most of patients didn't visit multiples times and majority of physicians worked at single hospital. In this case, the expected treatment outcomes could be impacted by patients, physicians and hospitals chars. However hospital could also impact physicians. So in this example, could I consider mixed effect model for physicians and hospitals level or only consider two fixed effects at two levels. Thanks! $\endgroup$ May 17 at 6:13

1 Answer 1


Ok, I think you want a model that has two sets of non-nested levels: you want a random physician effect and a random hospital effect. Whether it's a hierarchical model or not depends on your definition (and, I suppose, software), but it's a reasonably straightforward mixed model.

For example, in R's lme4 you could have a model specified by


where x1-x4 are predictors that could be at the patient or physician or hospital level and physician and hospital distinguish the physicians and hospitals

You could also describe the same model as a Bayesian linear or generalised linear model with a shrinkage prior on the doctor and physician factors and flat or weakly informative priors on the coefficients of $x_1\dots x_4$; you could fit it with Stan or JAGS, and probably with one of the more user-friendly interfaces like rstanarm or brms

I don't know if any of the software that describes mixed models hierarchically and uses maximum likelihood will fit these non-nested models (eg HLM) will fit these models, but someone else might comment.

  • $\begingroup$ Thank you for the comments. I know that a mixed model contains random effects. But could you please explain why I want to a random effect instead of fixed effects? $\endgroup$ May 17 at 17:28
  • $\begingroup$ Because if they are all fixed effects this is just an regression model, so I assumed you wanted random effects for the multilevel structure $\endgroup$ May 18 at 4:15
  • $\begingroup$ Thank you. Do you suggest always consider random effects when there is a multilevel structure in the data? $\endgroup$ May 18 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.