# About linear mixed model design

I have a dataset which consists of test score (responsive variable), location (station), gender, and blood glucose concentration. It has been found that the test score has a positive linear relationship with blood glucose concentration. My aim is to find whether gender can influence the test score, regardless of location and blood glucose level. Gender and location has no interaction (no orthogonality). Each gender has its own four locations. Originally, I want to use the nested design, but my instructor said you can have a simple way to control the effects due to blood glucose and location. Can I use a linear mixed model which sets the blood glucose and location as random factors and gender as fixed factor?

Technically this can be done with a simple random effects design like so for just locations as random effects, where location has a random intercept.

test_score ~ gender + (1|location)


You could also add glucose level as a particular random slope within location, as subjects will vary by glucose level by location. Glucose can also be used as a fixed effect like gender:

test_score ~ gender + (1 + glucose|location)
test_score ~ gender + glucose + (1 + glucose|location)


The reason I included glucose as a fixed effect instead of a random effect is two-fold. First, glucose, unless people are binned into some arbitrary group, is a continuous predictor and would not be adequate as a random effect, as it likely has several values but not many participants per value. Additionally, I'm assuming because you are using glucose, your test score refers to medical testing. As such, I think that glucose would actually be theoretically valuable as a fixed effect rather than "noise".

The only real issue I think with this model is the number of locations. If you mean that each gender has 4 locations, that would mean 8 locations in total, in which a random effects design would be feasible. But if all genders have 4 locations in total, that's really stretching it, as people normally recommend at least 5 groups per random effects cluster (see citation below).

Harrison et al., 2018 has a great primer on mixed models if you are interested, which discusses some of the things I have noted here.