Interactions between levels in lme4

We are implementing multilevel models in lme4 and have a question about how to handle cross-level predictors. This is a psychology experiment where individual participants come into the lab and complete multiple trials of the same task (e.g., judging how much they like a picture). To describe our dataset, we have trials nested within participants. These trials also have a trial-level predictor (e.g., how happy the participant rated they were before they made the judgment), and we might be interested in the relationship between happiness and liking (both rated on a 1-7 scale and treated as a linear variable). Modeling this with a random intercept for participant would be:

lmer(liking~happiness + (1|participant), data)

Now, in these data we also have three distinct races completing the experiment (e.g., participants that self-identify as white-only, black-only, or hispanic-only). Each participant only belongs to 1 race, and each race contains multiple participants.

We hypothesize that trial-level happiness will interact with participant-level race to predict liking. To test this model, we believe lme4 will detect that race is a group-level factor (since only one value exists for each participant) and that we would run:

lmer(liking~happiness*race + (1|participant), data)

However, based on other reading, we're wondering if this should instead be treated as a nested or random slope. For instance, should we instead use:

lmer(liking~happiness*race + (1| race/participant), data)

or

lmer(liking~happiness*race + (1 + happiness | race/participant), data)

Again, we are interested in the interaction between race and happiness in predicting liking, and each participant only belongs to one race. Thank you in advance for your help!

PS: We have looked at Specifying Cross-Level Interactions in LMER but this seems to represent a different data structure.

The general principle here is that it only makes sense/is only possible to estimate within-level variation for factors that actually vary within that level in the course of the experiment/observation period. Since happiness might vary within individuals across trials, but race can't, the maximal model you can fit would be

lmer(liking~happiness*race + (happiness|participant), data)

In other words, the effect of happiness on liking may vary across individuals; you will get estimates for

• (fixed) average effect of happiness on liking for the "baseline" race (whichever is the first level of your factor)
• (fixed) average effect of race (differences in liking from the baseline race) on liking for happiness zero (you might want to center happiness so that the 'zero' level of happiness is a more meaningful level [e.g. a baseline level of 4, or a baseline level of the mean happiness across the study population]
• (fixed) race-happiness interaction (the average difference in the happiness-liking slope between the baseline and other races)
• (random) among-individual intercept variation (difference in the expected liking of an individual at the baseline happiness from the expected liking for an individual of their race at the baseline happiness)
• (random) among-individual happiness-slope variation (difference in the expected effect of 1 unit of liking on happiness from the average effect for an individual of their race)

You could change the interpretation of the fixed factors slightly by changing contrasts.

To stretch a point a little bit, it might be possible in principle that the effect of race, or the happiness by race interaction, could vary across individuals, but you can't measure it. (This discussion would make more sense if considered in terms of a characteristic that is more likely to vary within individuals over some reasonable time scale but doesn't vary within individuals within the scope of the experiment.)