Skip to content

Is there an easy way to generate linearly independent vectors

2 messages · Fred, Jonathan Baron

#
On 06/17/04 19:04, Fred wrote:
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