title: Error in Stepwise regression: Error in terms.default(object) : no terms component nor attribute"
body: <p>I am working on a stepwise regression but am running into an error at the forward step:</p>
  
  <pre><code>Error in terms.default(object) : no terms component nor attribute
  </code></pre>
  
  <p>And I am not sure what to do about it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>FullModel &lt;- glm(Disease ~ age2 + Race2 + Gender + Lab1+ Lab2 + Lab3 + Lab4 +Lab5 + Lab6 + Lab7, family=binomial, data=Data)
  
  EmptyModel &lt;- glm(Disease ~ 1, family=binomial, data=Data)
  
  Data&lt;-na.omit(Data)
  backwards = step(FullModel) 
  formula(backwards)
  
  Data$forwards &lt;- step(Data$EmptyModel,scope=list(lower=Data$EmptyModel,upper=Data$FullModel), direction="forward")
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>terms.default(object) : no terms component nor attribute
  </code></pre>
  
  <p>To trouble shoot, I checked to make sure that the class of the objects used were correct:</p>
  
  <pre><code>&gt; class(EmptyModel)
  [1] "glm" "lm" 
  &gt; class(FullModel)
  [1] "glm" "lm" 
  </code></pre>
  
  <p>Any suggestions?
  Thank you kindly, in advance.</p>