title: How to add a random intercept and random slope term to a GAMM model in R
body: <p>I am trying to specify both a random intercept and random slope term in a GAMM model with one fixed effect.</p>
  
  <p>I have successfully fitted a model with a random intercept using the below code within the <code>mgcv</code> library, but can now not determine what the syntax is for a random slope within the <code>gamm()</code> function:</p>
  
  <pre><code>M1  = gamm(dur ~ s(dep, bs="ts", k = 4), random= list(fInd = ~1), data= df)
  </code></pre>
  
  <p>If I was using both a random intercept and slope within a linear mixed-effects model I would write it in the following way:</p>
  
  <pre><code>M2 = lme(dur ~ dep, random=~1 + dep|fInd, data=df)
  </code></pre>
  
  <p>The <code>gamm()</code> supporting documentation states that the random terms need to be given in the <code>list</code> form as in <code>lme()</code> but I cannot find any interpretable examples that include both slope and intercept terms. Any advice / solutions would be much appreciated. </p>