I want to make sure I'm properly accounting for the mixed effects in my model.

I am measuring characteristics of patient's eye's with disease and without disease, and determining whether a certain measurement is affected by a few features, sometimes at different time points. The measurement's are taken either of the right, left, or sometimes both eyes. There is no significance as to why it might be measured in both eyes for some patients and not others.

Sample Dataset:

Subject Eye Measurement_1 Measurement_2  Time   Disease
   A     R       3             3         1990     0
   B     R       4             2         1990     1
   B     L       2             1         1990     1 
   C     L       1             3         1990     0
   B     R       6             4         1991     1

So based on the above, I wanted to control for inter-eye variation via the following:

lmer(Measurement_1 ~ Disease + Measurement_2 + (1|Subject/Eye)

Now, if I only look at subjects in 1990 (as sometimes occurs when I need to run subsets on the data), I run into the error that the number of levels of each grouping factor must be < number of observations. I assume this error is because the Subject:Eye factor is equal to the number of rows when I'm only looking at patients in 1990.

Question #1: Is it appropriate in the above example to control for inter-eye variation simply with the mixed effect term: (1|Subject)? My concern is that there are possibilities for differences within the eye's of a single subject. For example, based on whether they use a treatment drop in one eye more than the other, or whether a disease had manifested more in one eye instead of the other. So would 1|Subject properly account for that?

Question #2: What is the best way to approach accounting for some patients who had repeated measurements at a different in time? Would it be better to include time as a Fixed effect or to include it as a mixed effect variable?


Regarding Question 1, you ask about whether it is sufficient to include the (1|Subject) term to account for the random variation between different eyes of the same subject. It isn't. However, you actually specify the random effects as (1|Subject/Eye) which would account for this, as it expands to (1|Subject) + (1|Subject:Eye), however these random effects are not identified when using a subset of the data because you have only 1 replication per Subject:Eye. This may be resolved by including multiple replications (ie. other years when the same Subject:Eye observation is made) and accounting for the "effect" of Time by including it as a fixed effect. It is not clear from the OP why you wish to subset the data (note that this will also result in a loss of statistical power). If you include Time as a fixed effect and use all the data, this is often a better way to model subgroups.

Regarding Question 2, this will depend on a few things. Initially I would suggest using Time as a fixed effect. Depending on the number of observations per subject and/or whether there is a non-linear "effect" of time you may wish to treat Time as categorical or numeric, and if treating it as numeric it might be better to re-scale the variable to begin at zero. If you expect the "effect" of time to be purely random, and only wish to control for it as a nuisance variable, the you could treat is as random with (1|Time).

| cite | improve this answer | |
  • $\begingroup$ Thanks for this comment. It is interesting, it seems like most papers account for inter-eye correlation by only using 1|Subject, rather than the nested approach as I mentioned above. See here: "The mixed effects model explicitly accounts for the correlations between paired eyes of a subject by adding a random intercept, the intercept is constrained to be the same for the two eyes of a subject, but different across different subjects." ncbi.nlm.nih.gov/pmc/articles/PMC5988240 $\endgroup$ – Tim Oct 28 '19 at 1:03

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.