apply() is just a for() loop internally so why do you expect it to be
faster?
Some comments:
1) Here predict() is just extracting the fitted values.
2) Using lm.fit will be faster if fitted values is all you want.
3) You are actually regressing each column on all other columns plus an
DeaR list
I would like to predict the values of each column of a matrix A by
regressing it on all other columns of the same matrix A. I do this with
a for loop:
A - B - matrix(round(runif(10*3,1,10),0),10)
A
for (i in 1:length(A[1,]))B[,i] - as.matrix(predict(lm(