Is there a way to use apply like functions instead of the for loop in the code below?
a <- array(rnorm(100,0,1), c(10, 5, 2)) ; a
b <- matrix(rnorm(20,0,1), 10, 2) ; b
m <- matrix(NA, 10, 2) ; m
for (i in 1:2){ m[,i] <- fitted(lm(b[,i]~a[,,i])) }
m
Many thanks