Displaying 1 result from an estimated 1 matches for "current_column_index".
2005 Jun 16
1
regressing each column of a matrix on all other columns
...trix(predict(lm( A[,i] ~
A[,-i] )))
B
It works fine, but I need it to be faster. I've looked at *apply but
just can't seem to figure it out.
Maybe the solution could look somewhat like this:
mylm <- function(y,ci) {
x <- A[,-ci]
b <- lm(y~x)
}
B <- apply(A,2,mylm,ci=current_column_index(A))
Is there a way to pass the index of the current column in apply to my
function? Am I on the right path at all?
Thanks for your help.
Regards, Stefan