# How to compare groups in different measurements using lmer (lme4)?

I have a problem building my lmer formula to perform an analysis.

I have two groups (healthy subject and patient) and numeric values in different brain regions (8 regions of interest) with a total of 63 subjects. I want to know the difference in these brain values between healthy subjects and patients for all of the regions. Plus I have to account for genotype (two types) and sex (male/female) and also a couple of other factors (mostly numeric).

So according to a similar publication, where lmer was used, I should put group (healthy/patient) and genotype as fixed factors and region should be put as within-subject fixed factor with a diagonal covariance structure. Participant ID should be a random factor.

I tried to build the formula in several different ways after looking for solutions online but I think I need help.

With disregard to the diagonal covariance structure, I tried it like this:

lmer(lk3 ~ group + (1 |region:ID2) + genotype +  (1|ID2), data = m)
OR
lmer(lk3 ~ group * region + (1+region*group|ID2), m)
OR
lmer(lk3 ~ group * region + genotype + (1|ID2) , m)


It outputs this error message for the first two: "number of levels of each grouping factor must be < number of observations"

I tried several other variants according to youtube videos and online discussions I read online but nothing seems to work, or when it does work I run an anova over the model and there is no p value.

How would you build the syntax for this model?

And how can I add the diagonal covariance structure for the regions as within subject fixed factor?

my data look like this:

'data.frame':   504 obs. of  7 variables:
$ID2 : Factor w/ 63 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...$ group   : Factor w/ 2 levels "healthy","patient": 1 1 1 2 2 2 2 2 2 2 ...
$sex : Factor w/ 2 levels "0","1": 2 2 1 2 1 1 1 1 1 1 ...$ age     : num  25 34 34 19.3 27 ...
$genotype: Factor w/ 2 levels "0","1": 1 1 1 2 1 1 1 1 2 2 ...$ region  : Factor w/ 8 levels "ACC","amygdala",..: 5 5 5 5 5 5 5 5 5 5 ...
\$ lk3     : num  0.205 0.17 0.172 0.149 0.193 ...


Thank you in advance, help much needed.

The article you refer to is: Watts JJ, Jacobson MR, Lalang N, et al. Imaging Brain Fatty Acid Amide Hydrolase in Untreated Patients With Psychosis. Biological Psychiatry, 88(9):727-735, 2020. DOI: 10.1016/j.biopsych.2020.03.003.

It's not a great example of reporting statistical analysis. I have concerns about how they do the analysis as well.

The relationship between [11C]CURB λk3 and schizophrenia diagnosis, psychotic symptoms, sex, and duration of illness and untreated psychosis were tested using a random-effect linear mixed model with group and genotype as fixed factors, region of interest as a repeated within-subject fixed factor with a diagonal covariance structure, participant identification number as a random effect (including intercept).

I guess this sentence describes the following mixed-effects model:

lk3 ~ group * genotype * region + covariates + (1|ID)


I put in a three-way interaction between disease status, genotype and brain region because it's not clear what interaction were considered. However, the authors do let us know that:

Nonsignificant interactions were removed from the model.

This is bad statistical practice because the final p-values and confidence intervals do not take into account the preliminary p-value-based model selection step. This "releases" model degrees of freedom and the residual standard error gets smaller. With smaller standard errors, the coefficient estimates remaining in the model have better chance to reach statistical significance. Effective for finding significant results, ineffective for controlling Type I error at the advertised α level.

• thank you for your answer! Yes, I also thought, it is not very clear how they did it from the description. I tried it as you suggested, however, when I run the anova over it, I do not get me p values. Any ideas on how this can be done? I thoght maybe an RM-ANOVA is not right, as I can't account for mixed and random factors, although similar papers have used just ANOVA for something like this analysis. Sep 18, 2022 at 19:24
• I have no idea what exactly they do in the paper as there is they refer to a mix of ANOVA and LMM, SPSS and R. I'd probably stick to LMM in R. You can use the emmeans package to compute the comparisons. See the Sophisticated models in emmeans vignette for example. To get more help with how to use these package, consider providing a minimal reproducible example (it can be simulated data). Sep 18, 2022 at 19:31