# discrete random effect in mixed linear model?

I need to know how I can define a mixed linear model with a discrete random effect ? I really googled trough the whole internet and can‘t find any solutions. In the general formulation its necessary that the random effects are normally distributed. How can I make this fit ?

EDIT: Sure. I‘m currently writing my bachelor thesis. I analysied a dataset about the relationship between the mean of the monthly amount of the days people are sick. My predictor variable is the monthly salary and my random effect is the age. The age is written in groups like (20,30],(30,40],(40,50] and (50,60]. The random effect is also discrete. As Theory I habe to introduce the mixed linear model and within this I have to make clear how it is possible to model such a relationship as above, where the random effect is discrete. Because normally the effect is normally distributed. I really dont have an idea, because the mean of the monthly amount of days on which a person is sick isn‘t necessarly discrete so I think glmm‘s arent the solution.

EDIT2 Well, I want to show that the amount of days on which a person is sick falls if the amount of salary the person gets rises. The problem is that the salary also rises with higher age (nearly linear) as well as the amount of sick days rises (a little bit) so you have to take the age into account. Additional the age splits the data in groups, due to the fact that I have a dataset over 20 years, so one person is in several groups over the year with different amounts of sick days and a different salary. Intuitively I woulds say age is more a random effect than a fixed one. In general I just want to know how to describe theoretically a mixed linear model when the random effect is discrete. Most of the basic Examples of mixed linear models take discrete data as their random effects like grades of students in regard of their classes and so on, but nowhere is mentioned how to really handle this sort of data an what has to be considered.

• Could you please say more about the type of predictor that you are trying to model as a "discrete random effect"? More details about the rest of your model might help, too.
– EdM
Jan 9, 2020 at 21:10
• one paper but we really need a lot of context/details ... Jan 9, 2020 at 21:24
• Sure. I‘m currently writing my bachelor thesis. I analysied a dataset about the relationship between the mean of the monthly amount of the days people are sick. My predictor variable is the monthly salary and my random effect is the age. The age is written in groups like (20,30],(30,40],(40,50] and (50,60]. The random effect is also discrete. As Theory I habe to introduce the mixed linear model and within this I have to make clear how it is possible to model such a relationship as above, where the random effect is discrete. Because normally the effect is normally distributed. Jan 9, 2020 at 21:40
• I really dont have an idea, because the mean of the monthly amount of days on which a person is sick isn‘t necessarly discrete so I think glmm‘s arent the solution .. I hope this makes my question more clear. Sorry for the bad english btw Jan 9, 2020 at 21:40
• Please say more about why you want to treat age as a random effect rather than as a fixed effect. See this page for some guidance. Also, please edit your question to incorporate the information that you add in your comments into the question itself, as that makes it easier for others to find; also, comments sometimes get lost.
– EdM
Jan 9, 2020 at 22:42

It does not seem to me that you need discrete random effects. In particular, your model will be something along these lines

$$\begin{array}{lll} \texttt{Mean_Days_Sick}_{ij} & = & \beta_0 + \beta_1 \texttt{Mean_Salary}_{ij} + \beta_2 \texttt{Age}_{ij}^{30-40} + \beta_3 \texttt{Age}_{ij}^{40-50} + \beta_4 \texttt{Age}_{ij}^{50-60} +\\ && b_{i0} + b_{i1} \texttt{Age}_{ij}^{30-40} + b_{i2} \texttt{Age}_{ij}^{40-50} + b_{i3} \texttt{Age}_{ij}^{50-60} + \varepsilon_{ij}, \end{array}$$

where the random effects $$b_i = (b_{i0}, b_{i1}, b_{i2}, b_{i3})$$ follow a normal distribution.

This will model will postulate that measurements from the same participant in the same age category are more correlated than measurements from the same participant but from a different age category.

A couple of notes:

• Your outcome is the number of days sick per month, hence perhaps it would be more appropriate to model it using a Binomial distribution.
• In general, it is not a good idea to categorize continuous predictors. It would be better to treat age as continuous and perhaps use polynomials or splines if you suspect a nonlinear relationship.

As @Dimitris Rizopoulos notes in another answer, were you to model the age categories as random effects you would be assuming that the coefficients for the age categories represent a sample from an underlying normal distribution. Think about whether that is a realistic or a useful assumption.

In terms of being a realistic assumption, what is the underlying normally distributed population from which you would be sampling? It can be OK to have a random effect represented in your data by just a few samples from an underlying normal distribution, which might appear to be a discrete distribution. As the paper linked in a comment by @kjetil_b_halvorsen shows, it's possible to use a discrete distribution to mimic that underlying normal distribution. But would that represent your situation well? Given human lifespans, there is only a handful of non-overlapping 10-year age windows. So I question whether that's a realistic assumption in your case.

In terms of being a useful assumption, I would suspect some important systematic relationship between age and the number of sick days per month. People tend to get sicker as they get older. A systematic relationship like that would not be captured by treating coefficients for age categories as a sample from a normal distribution. A systematic relationship of a predictor with outcome is better handled by modeling as a fixed effect, most simply as a categorical factor (without the restriction to sampling from a normal distribution implicit in the random-effect model), maybe better as an ordered categorical predictor, and probably best as a flexibly modeled continuous predictor, as @Dimitris Rizopoulos also suggested.

There is, however, one important random effect you should be taking into account: the individuals in your sample. As you say in your second edit:

one person is in several groups over the year with different amounts of sick days and a different salary

so the individuals in your data would seem best to be modeled with random effects in some way.

Although modeling with a discrete random effect might not be useful for frequentist modeling in your situation, a Bayesian model would be quite amenable to your desire to treat a discrete predictor as a random effect. In Bayesian modeling parameter values are assumed to represent samples from underlying probability distributions. As the Wikipedia page puts it:

In Bayesian inference, probabilities can be assigned to model parameters. Parameters can be represented as random variables. Bayesian inference uses Bayes' theorem to update probabilities after more evidence is obtained or known.

In Bayesian modeling the fixed versus random distinction thus can disappear. If you wish to model a random effect based on some discrete distribution that would be quite natural. You would not have to assume an underlying normal distribution as tends to be the default for frequentist regression models.

In a frequentist approach I suppose you could consider specifying a particular type of distribution for random effects sampled from a discrete distribution. You would then have to specify the form of the likelihood to optimize based on the nature of that distribution, and deal with the ML versus REML issue in the optimization.