title: GAM model error
body: <p>My data frame looks like:</p>
  
  <pre><code>head(bush_status)
  distance  status count
         0 endemic   844
         1 exotic     8
         5 native     3
        10 endemic    5
        15 endemic    4
        20 endemic    3
  </code></pre>
  
  <p>The count data is non-normally distributed. I'm trying to fit a generalized additive model to my data in two ways so i can use anova to see if the p-value supports m2.</p>
  
  <pre><code>m1 &lt;- gam(count ~ s(distance) + status, data=bush_status, family="nb")
  m2 &lt;- gam(count ~ s(distance, by=status) + status, data=bush_status, family="nb")
  </code></pre>
  
  <p>m1 works fine, but m2 sends the error message:</p>
  
  <pre><code>"Error in smoothCon(split$smooth.spec[[i]], data, knots, absorb.cons, 
  scale.penalty = scale.penalty,  : 
    Can't find by variable"
  </code></pre>
  
  <p>This is pretty beyond me so if anyone could offer any advice that would be much appreciated!</p>