# [R] How to generate regression matrix with correlation matrix

Spencer Graves spencer.graves at pdf.com
Fri Jul 11 23:53:50 CEST 2003

```	  What problem are you really trying to solve?  The problem statement

1.  Orthonormal means X'X = Identity matrix (10 x 10).  That means
the pairwise correlation coefficients can NOT be different from 0.

2.  Not all symmetric matrices with 1's on the diagonal and random
numbers U(-1, 1) on the off diagonal are correlation matrices.  Consider
the following example:

Cormat <- array(c(1, -0.9, -0.9, -0.9, 1, -0.9, -0.9, -0.9, 1),
dim=c(3,3))
> Cormat
[,1] [,2] [,3]
[1,]  1.0 -0.9 -0.9
[2,] -0.9  1.0 -0.9
[3,] -0.9 -0.9  1.0
> eigen(Cormat)
\$values
  1.9  1.9 -0.8

The fact that one eigenvalue is negative means that this "Cormat" is not
positive definite.

hope this helps.  spencer graves

rui wrote:
> Dear R community:
>
> I want to simulate a regression matrix which
is generated from an orthonormal matrix X of
dimension 30*10 with different between-column
pairwise correlation coefficients generated from
uniform distribution U(-1,1).
>