This might be a basic question, but I struggle to find a clear answer to this online.

Let's assume I am measuring heart rate under different activities such as running, walking, and resting. I have made these measurements on 100 different people, and for each individual, I have 20 measurements per activity. That means I have 100 x 20 (measurements) x 3 (activities) observations. I am of course interested in the effect of activity on heart rate.

My usual inclination would be to fit a general linear model like this:

HR ~ Act + Person

I would include the Person variable as a dummy to account for differences between individuals that affect heart rates, such as fitness and age. However, I could also fit a mixed effects model like this:

HR ~ Act + (1|Person)

In the second case, I am fitting one fixed intercept plus 100 random intercepts, one for each individual. In the first case, I am fitting one intercept for individual 1 plus 99 dummies for all the other individuals. It would expect the second approach to be superior, but I can't quite put into words what the difference would be. I am not very familiar with mixed models, so if I am making a mistake in the specification of the model, please let me know.


For the specific situation you've described, with 100 people, the linear model will, if using default contrast coding, produce 101 estimates: 1 for Act, 99 for person and 1 for the intercept (which will include the reference level of person). On the other hand, the mixed model will produce 1 estmate for Act, one for the intercept and a variance of the random intercept for person.

For these reason alone I would be inclined towards a mixed model.

However, on a more general level this is really just a question about when to treat a factor as fixed and when to treat it as random, and this has been asked and answered a number of times:

What is the difference between fixed effect, random effect and mixed effect models?

Random and fixed factors

Are anxiety measure fixed or random factors in this scenario?

Should I consider time as a fixed or random effect in GLMM?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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