lmer with random effects that is also associated with fixed effect I have data of compassion ratings in response to stimuli (pictures). The stimuli can be described by two factors, valence (categorical: positive, negative) and arousal (continuous). All n=145 subjects rated all 44 pictures. The ratings are continuous from 0 to 100 and are normally distributed for both positive and negative pictures. Here is what the data looks like for the first 3 subjects and 2 stimuli:
> df
  subject stimulus arousal valence
1   sub-1    pic-1    0.25     pos
2   sub-2    pic-1    0.25     pos
3   sub-3    pic-1    0.25     pos
4   sub-1    pic-2    0.48     neg
5   sub-2    pic-2    0.48     neg
6   sub-3    pic-2    0.48     neg

I want to analyse this data with a linear mixed model, however, I am a bit unsure about the random effects. In my experiments before, I always modelled both stimulus and subject as random effects, so my first instinct was to do somthing like this:
formula = rating ~ valence * arousal + (1|subject) + (1|stimulus)

However, since I have also an effect of interest continuously describing the stimuli, I am unsure if this is correct. Since I have an effect of interest describing each oft the stimuli with exactly one value, is the stimulus then still random? Or would it be better to only use subjects as a random effect, e.g., like this:
formula = rating ~ valence * arousal + (1|subject)

Does anyone know which model is better suited to analyse my data? Or generally has suggestions which model to use to analyse this data?

Your first formula:
rating ~ valence * arousal + (1|subject) + (1|stimulus)

describes rating with a linear effect of arousal, one such effect per value of valence (the fixed effect interaction term) and offsets, one per subject and one per stimulus. That is totally fine. Those two last terms are called "random effects terms" only because, intuitively, the coefficients are fitted in a "more random way" than the coefficients in the fixed effect terms. The net result of random effects is that, in deciding for each subject dependent offset, the model "looks" at all the subject dependent offsets together and tries to keep them close to each other ("shrinkage"). I.e., the values of one subject will have an influence on the offset of another subject.
Removing the last term, as in your second formula, says that you don't expect some relevant change in offset for different stimulus values. Which of those models is more appropriate depends on your scenario, your expert knowledge, what your actual task is, and, of course, also on which fits best your data.
What is interesting, is that while considering subject/stimulus dependent offsets, you did not provide for subject/stimulus dependent linear effects of arousal (which might be totally appropriate).
As a final remark, with those models that consider all kinds of (random/fixed) interactions of the features, it happens easily that the models get too complex and might overfit your data. In general, you want to keep your model as simple as possible.
