Fred
2004-Jun-18 00:04 UTC
[R] Is there an easy way to generate linearly independent vectors
Dear R-listers: I am trying to test an algorithm on a set of linearly independent vectors {x1,x2,...,xn}. So anyone can give me a hint on generating these vectors in an easy way? Thanks for your points. Fred [[alternative HTML version deleted]]
Jonathan Baron
2004-Jun-18 00:45 UTC
[R] Is there an easy way to generate linearly independent vectors
On 06/17/04 19:04, Fred wrote:>Dear R-listers: > >I am trying to test an algorithm on a set of linearly independent vectors >{x1,x2,...,xn}.Well, here's an idea, for 10 vectors of length 10, as columns of a matrix m1. The 11th seems to be needed. m1 <- matrix(rnorm(110),10,11) for (i in 2:11) { m1[,i] <- resid(lm(m1[,i] ~ m1[, 1:(i-1)])) } Test it with cor(m1[,-11]) I'm sure there are better ways. Of course m1 <- matrix(rnorm(100),10,10) is ALMOST what you want. Jon -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron