You don’t.
Seriously. You shouldn’t do it. It’s a popular method in social science research, but most statisticians will advise you against it. Selecting or removing predictors based on significance will lead to inflated Type 1 errors, introduces undesired bias and will not provide you with informative insights. Others have written more elaborately about this, so have a look at some of these resources:
- Gelman: Why we hate stepwise regression
- Mundry, R., & Nunn, C. L. (2009). Stepwise Model Fitting and Statistical Inference: Turning Noise into Signal Pollution. The American Naturalist, 173(1), 119–123. https://doi.org/10.1086/593303
- Henderson, D. A., & Denison, D. R. (1989). Stepwise Regression in Social and Psychological Research. Psychological Reports, 64(1), 251–257. https://doi.org/10.2466/pr0.1989.64.1.251
The comments also have some additional reading material to further convince you: Do not use stepwise regression.
One response to “How to do stepwise regression in R?”
For some more simulations on bias induction by stepwise methods:
https://pubmed.ncbi.nlm.nih.gov/10513756
https://pubmed.ncbi.nlm.nih.gov/29174118