title: Logistic stepwise regression with a fixed number of predictors
body: <p>For a course I'm attending, I have to perform a logistic stepwise regression to reduce the number of predictors of a feature to a fixed number and estimate the accuracy of the resulting model.</p>
  <p>I've been trying with <code>regsubsets()</code> from the leaps package, but I can't get its accuracy.<br />
  Now I'm trying with <code>caret</code>, because I can set its metric to &quot;Accuracy&quot;, but I can't fix the number of predictors when I use <code>method = &quot;glmStepAIC&quot;</code> in the <code>train()</code> function, because it has no tune parameters.</p>
  <pre><code>step.model &lt;- train(Outcome ~ .,
                      data = myDataset,
                      method = &quot;glmStepAIC&quot;, 
                      metric = &quot;Accuracy&quot;,
                      trControl = trainControl(method = &quot;cv&quot;, number = 10),
                      trace = FALSE)
  </code></pre>
  <p>I've found this question, but the answer and the links don't seem to work for me.  <a href="https://stackoverflow.com/questions/47855807/stepwise-regression-using-caret-in-r">stepwise regression using caret in R</a></p>
  <p>If not with caret, what would be the best way to achieve the reduced model with fixed number of predictors?</p>