# Creating sex-specific quartiles as predictor in lmer()

I am using lmer() (lme4 package) in r to test whether a hormonal factor (x) predicts score on a mental health scale (y). I am using linear mixed models rather than a standard GLM because the outcome score is provided by 2 raters (i.e. multiple response data). My baseline model consists of 3 fixed factors: age (continuous), sex (m/f) and rater (person 1/person 2) and I would like to include my primary variable of interest, x, in a subsequent model.

My question is: how should I include x as an ordinal variable when x is very differently distributed among males and females (see density plots below).

• (I am aware of the information-loss that goes along with discretising continuous variables but in this particular context, specific hormone values are less interesting to me than group rankings. I think creating hormone groups would simplify results & aid interpretation)

Let's say I split the hormonal variable x into quartiles...

Should I create quartiles on the entire sample (top plot)? Thus resulting in 0 females in the top quartile & few males in the bottom quartile (a problem when it comes to group interactions)?

Or can I create sex-specific quartiles (middle plot for females; bottom plot for males)? And can these sex-specifc rankings...

Female: FQ1, FQ2, FQ3, FQ4
Male: MQ1, MQ2, MQ3, MQ4

... be merged into one group variable with just 4 response options (Q1, Q2, Q3, Q4) & included as a predictor in our linear mixed model?

I imagine there is something wrong with doing it the latter way (sex-specific quartiles) but I don't know what exactly that is. Is it a comparable issue to including a continuous variable that has been standardised within each sex but entered as 1 variable?

The ultimate aim is to compare models without x (Model 0) and with x (Model 1) and in subsequent models, to add interaction terms such as the x:sex interaction.

.

(This data has previously been discussed with regards to its random effects on this thread: Mixed Model using lme4 in R for multiple response data )

Most statisticians will tell you that categorizing a continuous variable is a bad idea, and I generally agree with that. In your case, you can allow the effect of continuous x to vary by a person's gender. This would then induce separate slopes of x for males and females as well as intercept values for males and females at x==0. It preserves all the information contained in the continuous measure of x. In terms of modeling in lme4, it is straightforward:

m1 <- lmer(y ~ age + rater + sex*x + (1|Subject), data=df)


You mentioned that interpretation might be easier if you created categories, and I'm not so sure about that given that you are proposing 4 categories at minimum (if using the entire combined distribution of x) or 8 categories - 4 based on the male and 4 more based on the female distributions. In the case that you use the combined distribution of x to create 4 categories, you would need to add interactions between sex and three of the categories, producing male and female mean values on the outcome for the different categories of x. If you produce categories separately for males and females, that will be perhaps even more challenging to interpret.

On the other hand, if you keep x continuous, you can use ggeffects or effects to plot the interaction to aid in interpretation$$^*$$:

require(ggeffects)
ggpredict(m1, c("sex", "x")) %>% plot()


This will produce a nice plot that shows you the model-implied marginal association between x and y for males and females. See extensive documentation for ggeffects here.

$$^*$$You can also use ggeffects for plotting the interactions if you categorize x.