x <- matrix( rnorm(100 * 10000), ncol = 10000 )
y <- rnorm(100)
r <- cor(y, x) ## correlation of y with each of the xs
a <- allbetas(y, x) ## the coefficients of each simple linear regression of y with x
b <- matrix(nrow = 10000, ncol = 2)
for (i in 1:10000) b[i, ] = coef( lm.fit( cbind(1,x[,i]), y ) )
x <- matrix( rnorm(100 * 10000), ncol = 10000 )
y <- rnorm(100)
system.time( allbetas(y, x) )
system.time( for (i in 1:10000) b[i, ] = coef( lm.fit( cbind(1,x[,i]), y ) ) )
Run the code above in your browser using DataLab