# Thread: Random intercept only for 1 subgroup in lmer

1. ## Random intercept only for 1 subgroup in lmer

Dear all,
suppose I have a case study with 3 different populations, A, B and C. For all groups I have data on, e.g. body mass, length and sex of a given species. For group A I also have information on the year of birth, which I may be interested to include in the analysis as a random term to account for the cohort effect, while for groups B and C I have no such information. The dataframe would look something like:

Pop Coh Weight Length Sex
A 2010 12.1 34 m
A 2011 13.4 42 m
A 2012 10.3 36 f
A 2010 10.5 32 m
A 2013 12.1 37 f
A 2014 12.4 35 f
A 2011 14.1 32 f
...
B NA 13.1 36 m
B NA 10.5 35 f
B NA 12.4 32 f
B NA 12.6 35 m
...
C NA 13.7 31 m
C NA 11.5 37 f
C NA 10.7 33 m
C NA 11.9 35 f
...

Let's now suppose I want to investigate the relationship between Weight and Length, for males and females of different populations, e.g. by using a 3-way interaction. Would it still be possible to run the analysis in one single mixed model with a random intercept (cohort) only for group A?

With my actual dataset, the model

lmer(Weight ~ Length * Sex * Pop + (1 + Pop | Coh) )

fitted changing NAs to 1 appears to work, as it returns the same estimates for population B and C (but clearly not A) as the model

lm(Weight ~ Length * Sex * Pop)

but I am not quite sure if this is the correct approach.

Thanks!

2. ## Re: Random intercept only for 1 subgroup in lmer

So year is a continuous variable or factor?

3. ## Re: Random intercept only for 1 subgroup in lmer

Both Pop and Coh are factors. The idea would be to fit a random intercept shared by individuals that have the same value for Cohort, and allow a random slope for different Populations. This makes biological sense, as the factor Cohort is meaningful within different levels of Population.

 Tweet

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts