Using R, I would like to run n iterations for generating n simple linear regression models using a training dataset to predict n sets of fitted values for the test data. This would involve storing the models and predictions in appropriate containers. I would also like to label the predictions using a vector of labels. The data are structured as follows:
X = c(1.1,2.3,3.4,4.5,5.8), Y = c(1.0,2.4,3.3,4.7,6.0) and the model would be like lm(Y.train~X.train) and the predictions would be like predict(lm, data = test_set). How would I set this up? Is there a better approach?
Thanks!