I would be very grateful for any suggestions and help regarding the creation of a linear mixed model with lmer4 package and the lmer function.

I have created an experiment which randomly assigned participants into 8 different conditions. Each condition presented a short video with an actor. The actors were varying in two conditions Sex and weight. So basically there were

  • 2 x normal weight males,
  • 2 x normal weight females,
  • 2 x obese weight males, and
  • 2 x obese weight females.

I have measured participants on multiple scales but essentially the response variable is whether they liked the video or not, expressed as a numeric score with highers scores meaning participants favoured video more (i.e., VideoLiking). I also collected additional control variables about participants, however, to simplify let's say I have only measured their Sex (factor, 2 levels) and Weight (presented as Body Mass Index).

What is important to understand here is that each participant really viewed only one video, that means that they have seen only normal weight male video for example but not the other 7 videos. So that means participants are nested within condition; however, not crossed across conditions.

The research questions are:

  • How does the VideoLiking variable differ across videos?
  • Is it mediated by gender and weight of actors?
  • Is it mediated by gender and weight of participants?

Simplified data structure would look like this:

RespondentID Condition         SexParticipans      WeightParticipans VideoLiking
numeric      factor (8levels)  factor (2levels)    numeric (BMI)     numeric

Jumping into lmer, I believe that this is the formula that could measure questions that I am looking for:

VideoLiking ~ 1 + SexParticipant + WeightParticipant + (1 + SexParticipant + WeightParticipant | Condition)

Is this a correct model specification? Is mixed model suitable for this task or should I go with some other method?

Thank you.


Based on comments and answer below I have tried to model the data with separate factors for Participant and Target (Video) using linear model (linear mixed effect and multilevel modelling does not apply here according to the answer), it seemed to produce sensible results while working in 2x2 design:

model = lm(VideoLiking ~ Weight_Target*Sex_Target*Sex_Participant*BMI_Participant, data)

However, when I included an additional independent variable called Script_Target (Level: Negative / Positive) the results had strange estimates. See below, (note Video_Liking scale has a minimum score of 4 and a maximum score of 20).

Data Head

    Condition Sex_Target  Weight_Target     Script_Read  VideoLiking
       7       Male        Overweight        Positive          14
       5       Male        Overweight        Positive          13
       8       Male        Non-Overweight    Positive          15
       5       Male        Overweight        Negative           9


model = lm(VideoLiking ~ Weight_Target*Sex_Target*Sex_Participant*BMI_Participant*Script_Target, data)


(Intercept)                               23.2873
Weight_TargetOverweight                   131.6127 <-- !
Sex_TargetMale                            -5.8691
Sex_ParticipantMale                       -18.7204
BMI_Participant                           -0.4091
Advice_TargetPositive Script              -7.7320

Considering that DV Video_Liking scale can only have scores up to 20, estimate with 131 does not make sense. I am not exactly sure why is this happening; however it only happened with additional IV.


1 Answer 1


You do not want a mixed effects model here. You randomly assigned people to conditions; you did not randomly sample people from an entire population of possible conditions (this would be a multilevel model).

So participants are not nested within condition; instead, participants were randomly assigned to one of 8 conditions. What you are looking for is not mediation, either, but moderation.

First, your eight conditions can be seen as a 2 x 2 factorial design. Collapse across the specific actors, and you only have four conditions: Normal weight males, normal weight females, obese males, and obese females.

You should create two variables from your Condition variable. I'm going to call the actor in the video a "Target." I'm going to call the participants "Participant."

  1. You should have a variable called Target_Weight, which can be either Normal or Obese

  2. And another variable called Target_Gender, which can be either Male or Female.

  3. Then you have the participant gender, Participant_Gender, and the participant BMI, Participant_BMI.

  4. The DV is then Video_Liking.

Each of these are between-subjects factors, so a regular regression can be calculated:

lm(Video_Liking ~ Target_Wieght*Target_Gender*Participant_Gender*Participant_BMI, data)

This will give you a rather unwieldy design where you will have a possible 4-way interaction. I can help you interpret that if you'd like, but that is how I would suggest analyzing the data.

Here is me discussing whether or not something is (a) a fixed factor or (b) something to nest within elsewhere on CV.

See here for materials on moderation vs. mediation. In short, mediation tries to explain a causal process. Gender and BMI are not considered mediators here, unless you think that the video could change someone's BMI or gender (very, very unlikely). Moderators are more about, "Who would this occur for?" Which, I think, is more of what you are interested in.

  • $\begingroup$ Thank you for suggesting this approach, I thought about it in past but I encountered difficulties understanding estimates of such model. In other words, if I approach conditions the way you suggest and create a similar factorial design, then estimates of the output lm() model have strange values that I do not comprehend. For example, if my Video_Liking scale has values from 1 to 20, the estimates I am receiving are well over this, for example, 131.6127 in Target_Weight_Obese. $\endgroup$
    – gofraidh
    Commented Jun 5, 2017 at 1:38
  • $\begingroup$ Would it be possible to post the head of your data, the code, and the output for that stuff? $\endgroup$
    – Mark White
    Commented Jun 5, 2017 at 1:39
  • $\begingroup$ Yes, I will try to, but I think I realised what may be the issue. The model you've suggested model = lm(Video_Liking ~ Weight_Target*Sex_Target*Sex_Participant*BMI_Participant, data) Results in sensible estimates. The problem occurred when I tried to insert into model another variable from the condition, that I have called Script_Target and it refers to script actors were reading. That would be model = lm(Video_Liking ~ Weight_Target*Sex_Target*Sex_Participant*BMI_Participant*Script_Target, data). Thinking purely intuitively, could it be because there is nothing like Participant_Script? $\endgroup$
    – gofraidh
    Commented Jun 5, 2017 at 1:53
  • $\begingroup$ I have edited the question above to show a sample of the head of data modelled, the code, and the output of estimates. $\endgroup$
    – gofraidh
    Commented Jun 5, 2017 at 2:13
  • 1
    $\begingroup$ How many participants do you have? That could be an issue. Since you are looking at a five-way interaction, you are estimating a whole lot of parameters. If your sample size isn't large enough, that could be what is giving you weird results. I would take a step back and think about what you are most interested in/what answers your hypothesis the best/what you had in mind before the experiment. I never look at more than a three-way interaction. After that, it becomes incredibly hard to interpret. $\endgroup$
    – Mark White
    Commented Jun 5, 2017 at 15:29

Your Answer

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

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