I have used a repeated-measures ANOVA in SPSS to analyse some of my data. It's the typical approach in my area, but I think it might be more appropriate to use a mixed effect model. However, I struggle with both building the model as well as interpreting it.

Experimental design

300+ participants from two different samples have rated on a continuous scale a stimulus at seven different manipulation levels. I want to test whether individual differences in the participants (recorded as ordinal or binary variables) interact with that rating score. In particular, I'm interested in whether the rating score changes as a function of stimulus level differently in people that, for example, feel mainly attracted to men or women.

Thus, I have a within-subjects factor (stimulus level), a between-subjects factor (such as being attracted to men or women), and a random effect of participant nested in sample.

I've been using lmer() from the lme4 package and lmerTest and have come up with the following model

model <- lmer (rating.score ~ stim.level + factor + stim.level*factor +
                                                     (1|participant) + (1|sample), mydata)


  1. Is lmer() the right package to work with?
  2. Am I appropriately accounting for the random effects of participant and sample, or do I need something like (1|sample/participant)? I followed the Pastes data example, but am not sure that's the right thing to do in this context.
  3. Based on previous literature, I expect the relationship of rating.score and stim.level to be quadratic - should/could I enter stim.level as squared term?


In SPSS, I find a significant interaction of stim.level x factor. By visualizing the interaction and running post-hoc tests I can then interpret the nature of that interaction. In R, I get estimates of the interaction at each level of stim.level, some of which are significant, some of which are not. Can I still make the conclusion that factor affects the relationship of rating.score and stim.level (even though not necessarily to the same extent at each level)?

EDIT: I just realized I had entered stim.level as a factor. I think it is appropriate to enter it as a linear variable - the different levels correspond to the same manipulation applied with increasing extent (the steps between each level are the same). This also resolves one of my earlier questions regarding an error message when trying to model random slopes which I have thus now removed.

  • 2
    $\begingroup$ You really have a nested model so you do need to have your R code alone the lines of (1|sample/participant) to account for the nested structure. Also can you give some more info about the response? I see it is a rating score-- is that a scale 1 to 10 for instance? $\endgroup$ Jun 23, 2015 at 18:12
  • $\begingroup$ @LaurenGoodwin Cheers! Re the response variable, I wasn't sure how much detail to put in the question - the original rating indeed was made on an 8-point Likert-type scale. Participants rated a total of four base stimuli (at the seven different levels, i.e. 28 trials in total). As I'm not interested in differences between the base stimuli, I averaged responses for each stimulus level, ending up with a (pseudo?-)continuous response variable. $\endgroup$
    – A. Dent
    Jun 23, 2015 at 20:46

1 Answer 1


okay should work out okay then-- so

  1. Yes or you can use the lmer() and lme4. There is another one but I don't remember off the top of my head I think it is just lme?

2.You have a nested structure so yes you need (1|sample/participant)

  1. Did you plot rating score vs stim.level to see evidence of a quadratic relationship? If not try plotting to see-- i you do see a quadratic pattern then yes you should add stim.level quadratic effect by

    model <- lmer (rating.score ~ stim.level + I(stim.level^2) factor + stim.level*factor +(1|sample/participant) , mydata)

To reply to the comment

so if you are fitting a parabola and not a line you are fitting the generic

 y= a + b*x + c*x^2 

so you need the linear and quadratic term so stim.level is the linear term and I(stim.level^2) would be the quadratic term. Try writing your model out on paper in equation form like

rating score = b_0 + b_1 * stim.level + b_2 *stim.level^2 + b.3*(stim.level*factor)

and if wanted you could have an interaction with the squared term but that might not be directly interpretable. 2) Remember you are fitting a parabola NOT a line http://biopt.ub.edu/_/rsrc/1257372769717/force-detection/equipartition-theorem/ex4%20X%20potential.jpg?height=315&width=420 something that looks like that. Did you plot stim.level against rating.score and see a quadratic relationship?

  • $\begingroup$ Not sure whether a new thread would be better, but I have two follow-up questions: 1) could you maybe explain I(stim.level^2)*factor? Instead entering stim.level.sq+stim.level.sq*factor gives different results (I centered stim.level before squaring) 2)I find a significant main effect of quadratic but not linear stim.level (both have a negative slope), and a significant interaction of the linear but not the quadratic term with factor. Is it surprising the main effect of the linear term is not significant? How would I interpret a significant interaction of factor and stim.level.sq? $\endgroup$
    – A. Dent
    Jun 24, 2015 at 21:29
  • $\begingroup$ I updated my response to respond to your comment. $\endgroup$ Jun 25, 2015 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.