title: How do I specify random effects using gamm models in R?
body: <p>I am using gamm models in mgcv package to analyse how specific diversity measures eg. Shannon vary over time and with environmental variables eg. temperature.</p>
  
  <p>I have the initial model so far to analyse time series: </p>
  
  <pre><code>modf&lt;-gamm(y~ as.factor(year) + s(doy,bs='cc',k=kdy),method=mth,correlation=tcor,data=d,
             control=ctrl,random=NULL,gamma=1)
  </code></pre>
  
  <p>I want to include temperature as random effect and thought of doing something like:</p>
  
  <pre><code>modf&lt;-gamm(y~ as.factor(year) + s(doy,bs='cc',k=kdy), + s(temp,bs="re"),method=mth,
             correlation=tcor,data=d,control=ctrl,gamma=1)
  </code></pre>
  
  <p>However, so far I have only seen this for gam not gamm. Does it still work this way?</p>
  
  <p>An example of type of data structure:</p>
  
  <ul>
  <li>$ total_abundance: num  6364161 1929775 7057036 1266342 3981198 ...</li>
  <li>$ shannon        : num  1.87 2.08 1.95 1.84 2.06 ...</li>
  <li>$ turnover       : num  0.613 0.475 0.525 0.556 0.429 ...</li>
  <li>$ year           : int  1985 1986 1987 1987 1987 1988 1989 1989 1991 </li>
  <li>$ month          : int  8 12 3 7 8 5 1 8 1 9 ...</li>
  <li>$ day            : int  20 8 15 6 17 9 16 29 14 4 ...</li>
  <li>$ temp           : num  25.5 9.87 4.8 19.72 26.03 ...</li>
  <li>$ doy            : num  232 342 74 187 229 130 16 241 14 247 ...</li>
  </ul>
  
  <p>where doy is 'day of year' and accounts for seasonality</p>
  
  <p>Thanks</p>