title: using anova to compare two linear models of unequal sample size: error
body: <p>Here is an example of what I want to do, with a randomly generated number set:</p>
  
  <pre><code>a &lt;- runif(100, min =0.5, max=1);
  b &lt;- runif(100, min = 0, max =1);
  c &lt;- factor(rep(c("High", "Low", "High", "High"), times = 25));
  
  df&lt;-data.frame(a,b,c);
  
  head(df)
  
   a          b           c    
  1 0.9506028 0.84686708 High    
  2 0.7296878 0.24566532  Low    
  3 0.6208635 0.90166263 High    
  4 0.9009880 0.98464187 High    
  5 0.6032242 0.23613096 High    
  6 0.5409369 0.06325577  Low
  </code></pre>
  
  <p>So what I want to do here is to create two separate linear models, one for subsetted data (c=="High", n=75), and another for subsetted data (c=="Low", n=25)........</p>
  
  <p>...Then I want to run an anova to compare the linear models:</p>
  
  <pre><code>mod1&lt;-lm(b~a, data=df, subset = c=="High")
  
  mod2&lt;-lm(b~a, data=df, subset = c=="Low")
  </code></pre>
  
  <p>Up to this point everything works great, but the next command:</p>
  
  <pre><code>anova(mod1,mod2)
  </code></pre>
  
  <p>Produces an error:</p>
  
  <blockquote>
    <p>Error in anova.lmlist(object, ...) : 
          models were not all fitted to the same size of dataset</p>
  </blockquote>
  
  <p>This issue may be solved using the update function, although I have yet to come across an example showing how to update the subset function within the lm call line.</p>
  
  <p>Thanks :)</p>