How to do a loop as follows - stepwise regression, exclude coefficients > 1,000, stepwise regression, repeat


#1

Hi there,

So I understand how to do a stepwise regression, for instance:

fit <- step(lm(y~x, data=df)

Is there a way to create a loop that would work as follows:

  1. stepwise regression - call it "fit"
  2. re-run stepwise regression excluding coefficients > 1,000 from "fit"
  3. continue process until all coefficients are <= 1,000

Thank you