title: How to extract the correct model using step() in R for BIC criteria?
body: <p>I am trying to select the best model using AIC and BIC criterion using Boston dataset. I have got the best model according to AIC criteria. For the BIC criteria I used the following code: </p>
  
  <pre><code># Selecting best possible model using BIC
  lm.BIC&lt;-step(lm.null,scope = list(lower = lm.null, upper = lm.full), direction = "both", trace = TRUE, k = log(nrow(training)))
  </code></pre>
  
  <p>The output of the above code is below: </p>
  
  <p><a href="https://i.stack.imgur.com/VcdIc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VcdIc.jpg" alt="enter image description here"></a></p>
  
  <p>It spit out models with decreasing AIC values. I checked the BIC values for the last model (call model 1 <code>medv ~ lstat + rm + ptratio + black + dis + nox</code>) and another model (call model 2 <code>medv ~ lstat + rm + ptratio + black + dis + nox + rad + tax + zn</code>). Model 2 with three extra variables. I found that BIC values for model 2 is less than model 1. So I am confused how to extract the best BIC model using the above line of R code and its output when all it shows are AIC values, which I don't want to judge my models on. </p>
  
  <p>Thank You</p>