<p>I have to disagree with the other answer that quotes Barr et al (2013) to &quot;keep it maximal&quot;. This has been proven to be bad advice on so many occasions that the authors of lme4 had introduce code to check for singular fit. Not only that but Doug Bates (primary author of lme4 and probably the worlds leading authority on mixed models) and colleagues wrote a paper in 2015 specifically adressing problems brought about by the wish to &quot;keep it maximal&quot;  -  <a href="https://arxiv.org/pdf/1506.04967.pdf" rel="nofollow noreferrer">Parsimonious Mixed Models</a>.</p>
<p>Of course I am not saying that checking for singular fits is a bad thing - it's a great thing, so something good certainly came from it.</p>
<p>So in this case we have <code>(task * stimulation|subject)</code> where <code>task</code> has 4 levels and <code>stimulation</code> has 3 so we are asking the software to estimate 8 variance-covariance parameters with only 20 subjects. I am not saying that this is impossible, but it just seems bizarre to me for this to be the goal. The Bates et al (2015) paper goes into considerable detail about how to handle the resulting problems and I have answered some questions on CV about how to do so <a href="https://stats.stackexchange.com/questions/378939/dealing-with-singular-fit-in-mixed-models/379068#379068">here</a> and <a href="https://stats.stackexchange.com/questions/449095/how-to-simplify-a-singular-random-structure-when-reported-correlations-are-not-n/449122#449122">here</a></p>
<p>So in summary, the other answer isn't necessarily wrong, but it can lead to a lot of problems.</p>
Correct model in R using lmer
<p>I have a question regarding the correct model setup in R using lmer.</p>

<p>This is a repeated measures experiment</p>

<p>Each subject (20 in total) completed 4 different task for each stimulation condition (anode, cathode, and sham). The dependent variable is reaction times (rt)</p>

<p>I used this model but I am not sure if its correct. I am more concerned if the random effects are correctly assigned</p>

<pre><code>model&lt;- lmer(rt ~ task * stimulation + (task * stimulation|subject), data=dat)
</code></pre>

<p>Any help will be appreciated.</p>

<p>Thank you</p>