How to create a loop for a regression model?