title: Perform a repeated measures ANOVA using mixed model
body: <p>My design is as follow : subjects had to complete a response-time based task. Each trial of this task was defined by a combination of four factors :</p>
  
  <ul>
  <li>Factor 1 (F1) : 2 levels</li>
  <li>Factor 2 (F2) : 2 levels</li>
  <li>Factor 3 (F3) : 2 levels</li>
  <li>Factor 4 (F4) : 2 levels</li>
  </ul>
  
  <p>Each unique combination was repeated 4 times, resulting in a total of 64 trials (2x2x2x2x4), and each subject went through all 64 trials.</p>
  
  <p>As the four factors are within-subject factors, I was initially going with a repeated measure ANOVA with the four factors predicting the response-time (RT), using aov. I should add that I am interested in the interaction between the four factors. Looking through multiple guides, I came up with this code :</p>
  
  <pre><code>data.aov &lt;- aov(RT ~ F1 * F2 * F3 * F4 + 
              Error(subject / (F1 * F2 * F3 * F4)),
            data = my_data)
  </code></pre>
  
  <p>However, while gathering information on how to perform a repeated measure ANOVA using R, I read that it is not advised when there is an unbalanced number of repeats across individuals - unfortunately, this is my case, as I had to get rid of outliers (particularly high/low response times). I should rather use mixed models, which account for this lack of balance.</p>
  
  <p>I have been looking for examples on how to transpose a repeated measures ANOVA to a mixed model. So far, I managed to understand that my factors are fixed, but "subject" is random. However, all the examples I found did not include multiple factors as independent variables.</p>
  
  <p>My question is : what is the correct syntax for a mixed model with multiple predicting factors, especially regarding the error term ? I am using the nlme package.</p>