3
$\begingroup$

I've been sometimes taught that when you are performing a mixed model, any variable of which you don't care about estimating a parameter (adjusment variable) should be a random effect, regardless of number of added degrees of freedom.

However, in most online courses and tutorials (this one for instance), this is not really explicit.

Let's take the same example as this tutorial:

lmm <- lmer(Mean.Pitch ~ Sex + Social.Rank + (1 | Group), data = starlings,
    REML = FALSE)
summary(lmm)

If I'm only interested in Sex's effect, should I put Social.Rank in the random effects?

If this is true, what will it change? Then, should I perform mixed model even if there is no real grouping?

$\endgroup$
  • $\begingroup$ I have never seen such a claim about adjustment variables as random effects. What rationale did the teacher give for this? $\endgroup$ – Heteroskedastic Jim May 16 at 13:17
  • $\begingroup$ @HeteroskedasticJim The course was very practical (R course) so there was no time for maths and rationales... But regardless of this statement (which I'm glad I'm not the only one to find it surprising), I'm still interested on what changes if I adjust on some confounding variable with a fixed or a random effect. $\endgroup$ – Dan Chaltiel May 16 at 13:21
  • $\begingroup$ there are no changes all across the board. They just relate to different model specifications. Try reading about what it means to specify a variable as a random effect (at least in terms of interpretation). Also run it both ways and see. I would also say that if you don't know the rationale for that modeling strategy, then your first task should be finding one. $\endgroup$ – Heteroskedastic Jim May 16 at 13:25
  • $\begingroup$ @HeteroskedasticJim I dont understand why you are saying this, of course I'm looking for a rationale, this is why I'm posting here! Also, my math skills don't allow me to understand enough random effects to be sure I'm doing good (trust me I tried). Running it both ways won't help neither: I'll have 2 results, maybe close, and won't know which one is better. $\endgroup$ – Dan Chaltiel May 16 at 13:33
  • $\begingroup$ @DanChaltiel looking at your bio, I see you're a PhD in epidemiology. You don't have to do the complex math to understand models. But I also think you're understanding is deficient here (with all respect). I can recommend two (3) good non-technical (non-algebra, good examples, and detailed technical writing) books appropriate to PhD Epidemiology: Vittinghoff et al Regression Methods in Biostatistics. and Diggle, Heagerty, Liang Zeger "Analysis of Longitudinal Data". Also Wakefield "Bayesian and Frequentist Regression Methods". $\endgroup$ – AdamO May 16 at 13:45
6
$\begingroup$

That is not right. A mixed effects model is a mixture of random effects and fixed effects. Generally, the point of adjusting for a random effect is to control for clustering indicators or combinations of covariates that are so high in dimension, the fixed effects would be unstable if not singular in a model. Random effects are a kind of last resort in that sense.

Correlated data and model misspecification are highly related, random effects allow you to have a misspecified model, but to borrow information about groups of individuals who tend to be clustered, to yield residuals that are conditionally independent. If you managed to control for all those attributes in the fixed effects there's no need for a random effect at all. If anything, the preference should be to control for the fixed effect whenever possible because the inference is more generalizable.

Take, as an example, a study of fraternal twins. If you studied the phenotype of a heritable disease, and then adjusted for the genetic mutation (SNP) which predisposes individuals to that disease, the data are now independent despite the design because the only "relatedness" that the twins exhibited has been controlled for. There would be no need for a random effect indicating twin-pair in the outcome.

$\endgroup$
  • $\begingroup$ this is exactly what I thought but I wanted to make sure, thanks for the clear explanation $\endgroup$ – Dan Chaltiel May 16 at 13:46
  • $\begingroup$ I googled "confraternal", and there didn't seem to be any results other than to pages regarding confraternaties. Do you man just "fraternal"? $\endgroup$ – Acccumulation May 16 at 19:07
  • 1
    $\begingroup$ @Acccumulation yes I think I accidentally turned my twin research into a Catholic prayer. See edit. $\endgroup$ – AdamO May 16 at 19:14
8
$\begingroup$

The first and foremost consideration that should drive the specification of random effects in a mixed effects model is the study design. Here are some examples that illustrate how the design affects the model specification.

Example 1

If you have a study in which you randomly selected patients from a target population of patients and measured an outcome variable (e.g., CD4 cell count) at several time points, along with time-varying and/or time-invarying predictor variables, then you would want to include at a minimum a random patient effect (i.e., a random patient intercept) to account for the natural nesting of repeated outcome observations within a patient.

Example 2

If you have a study in which you randomly selected a set of hospitals from a target population of hospitals, and then you randomly selected a set of patients from each hospital such that each patient would provide multiple measurements for an outcome variable (e.g., CD4 count), then you would need to include (at a minimum) a random hospital effect and a random patient effect in your model.

-------------------------------------------------

In the first example, patient is a random grouping factor. In the second example, hospital and patient are random grouping factors, with patient nested within hospital (since the patients randomly selected within a hospital are unique to that hospital and will not appear in any other hospital).

In some study designs, it is possible to have either fully crossed or partially crossed random grouping factors. For instance, you could have a study where some patients end up attending multiple hospitals throughout the duration of the study, in which case the patient and hospital would likely be partially crossed random grouping factors.

So paying attention to the study design helps identify the random grouping factors, each of which will be allowed its own random set of intercepts in the model - one intercept per level of random grouping factor.

The second consideration in the mixed effects model specification is to think about what predictor variables in the model can have varying (or random) effects across the levels of the grouping factor(s).

For Example 1, let's assume we measured the predictor blood pressure for each patient at all the time points where we also measured the outcome variable CD4 cell count - there were 4 time points per patient (say, once a week, for a total of 4 weeks). Let's also assume we measured the predictor gender. The blood pressure values will change from one week to the other for each patient, in tandem with the values of the CD4 cell counts. If we have reasons to believe that the association between CD4 counts and blood pressure values will be different from patient to patient, then we can allow the slope of blood pressure in the model to vary randomly across patients - we can achieve this by including a random effect of blood pressure in the model. The gender value will not change from one week to another for a patient, so there is no need to allow for a random effect of gender in our model. In the context of this example, we say that blood pressure is a within-patient (or within-subject) predictor variable, whereas gender is a between-patients (or between-patients) predictor variable. Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor.

For Example 2, we can have predictor variables that refer to the hospitals included in the study (e.g., type of hospital) and/or predictor variables that refer to the patients within those hospitals (e.g., patient gender, patient blood pressure). The patient-specific predictor variables, for instance, can be within-patient predictors whose values change from occasion to occasion for the same patient, or between-patient predictors, whose values are invariant to occasion for each patient but change from one patient to another. The within-patient predictors can have varying (or random) effects across patients, etc.

So the inclusion of random effects in your model ultimately depends on whether your study design includes any random grouping factor (e.g., patient, hospital) and whether you have predictor variables whose effects can be assumed to vary across the levels of these random grouping factors.

$\endgroup$
  • 1
    $\begingroup$ +1, but "Only within-patient predictor variables can be allowed to have varying (or random) effects across the levels of the corresponding random grouping factor." This is not really true. If patients are measured four times, then there is information to compute a patient-level gender effect. The effect of gender can be allowed to vary across persons. Older ways of formulating the model do not allow for this hence this belief. But more recent model formulations, such as in lme4, allow for between-person variables to have effects that vary by person. $\endgroup$ – Heteroskedastic Jim May 18 at 15:24
  • $\begingroup$ @HeteroskedasticJim: Interesting! How can we compute the effect of gender within one subject when there is no variability in the values of gender within that subject? The effect of gender within one person would imply that when that person switches genders from male to female, say, there is a difference in the expected value of their response. The variability of the gender effects across subjects would imply that the difference would vary across subjects - so all those subjects would have to have a gender switch! Just trying to understand intuitively what is going on here. $\endgroup$ – Isabella Ghement May 18 at 15:52
  • 1
    $\begingroup$ Interesting approach to the issue. I see how if one thinks of a person-level dataset, you have a constant for gender alongside another constant (the intercept). But estimation works on the full dataset, and not on a person by person level. And if you look at model specification in lme4 (e.g. equation 2 in cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf), all that matters is that the design matrix for the random effects across all persons is a valid one, so no column is a linear combination of others; and there is information in the data to estimate the variance components. $\endgroup$ – Heteroskedastic Jim May 18 at 16:50
  • 1
    $\begingroup$ When the model is correctly specified, for females, the male random slope = 0, and vice-versa. Intuitively, the meaning is that the effect of gender is not the same for every human. A standard approach would be to interact gender and race. Here, it's an interaction between gender and person indicator. The difference would vary across subjects, yes. If A is fem and B, F are male. Then the difference "due to" gender comparing A to B is different than same "effect" comparing A to F. $\endgroup$ – Heteroskedastic Jim May 18 at 17:00
  • 1
    $\begingroup$ Yes, I'd answer the question if you post one. And I have an example in mind. $\endgroup$ – Heteroskedastic Jim May 18 at 17:13

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.