# How to include nested fixed effects with different levels across conditions in lmer?

My design is as follows:

1. one dependent variable (brain activity),
2. a "condition" factor I manipulated with two levels (c1 and c2)
3. a "region of interest" factor with two levels (r1 and r2) *note that not all subjects have data in both regions
4. a "subregion" factor with one level for r1 and three levels for r2 - this subregion is nested with roi. For example, region of interest can be visual cortex and auditory cortex. And I only have V1 as a subregion for visual cortex, but A1, A2 and A3 as subregions for auditory cortex.
    subject roi  subroi activity condition
s1      n1     v1    0.34      c1
s1      n1     v1    0.68      c2
s2      n2     a2    0.18      c1
s2      n2     a3    1.27      c1
s2      n2     a2   -0.77      c2
s2      n2     a3    0.16      c2
s3      n2     a1    0.12      c1
s3      n2     a1    0.42      c2


I'm mostly interested in the interaction between condition and roi, but would like to account for the fact that there are subregions (subroi) nested under roi.

Another important point is that each subject has a different number of electrodes, so I would need to account for shared variance within subjects.

1. Is the following model correct? lmer(activity ~ cond*roi + (1|roi:subroi) + (1|subject), data=dat)

2. If I do find a significant cond*roi interaction, can I run follow up analyses within each roi in the following manner: for n1 (with 1 level of subroi): lmer(activity ~ cond + (1|subject), data=dat) for n2 (with 3 levels of subroi): lmer(activity ~ cond*roi + (1|subject), data=dat)

I have come across several websites on nested effects, but most assume that the nested factor (subroi) has the same levels across the main factor (roi). The above code doesn't look exactly right to me given the asymmetrical levels of subroi across n1 and n2, but I cannot think of another way to account for that. Any thoughts/suggestions would be much appreciated!

Note I have changed patient to subject in your question, to be consistent with the data excerpt. I hope that is correct.

1. Is the following model correct? lmer(activity ~ cond*roi + (1|roi:subroi) + (1|subject), data=dat)
The problem with this is that you are specifying a random effect (in particular, random intercepts) for the roi:subroi interaction. However, this has only 4 levels, which is insufficient, at least in a frequentist framework such as lmer, as it's variance will be estimated poorly and numerical problems may also occur. Furthermore, this interaction is not specified as a fixed effect (which would not be possible anyway in the presence of roi as a fixed effect, due to the separation of levels between roi and subroi) so it would force the interaction to have an overall mean of zero (since the random effects have a mean of zero). So it would be better to remove (1|roi:subroi).
1. If I do find a significant cond*roi interaction, can I run follow up analyses within each roi in the following manner: for n1 (with 1 level of subroi): lmer(activity ~ cond + (1|subject), data=dat) for n2 (with 3 levels of subroi): lmer(activity ~ cond*roi + (1|subject), data=dat)
Neither model makes sense to me. For one thing, you are losing power by splitting the dataset. For another, with lmer(activity ~ cond + (1|subject), data=dat) you already have an estimate for the fixed effect of cond along with it's interaction with roi from your original model so this won't tell you anything new. For lmer(activity ~ cond*roi + (1|subject), data=dat) since there is now only 1 level of roi this will generate an error along the lines of contrasts can be applied only to factors with 2 or more levels and if you remove roi from the that model then my previous comment also applies. I wonder if you perhaps meant lmer(activity ~ cond*subroi + (1|subject), data=dat) which would make more sense.
• I think the roi:subroi interaction is degenerate, so that doesn't make sense. Jul 22, 2016 at 15:38