[R] Achieving 'reverse-Vech' of a matrix
Megh Dal
megh700004 at yahoo.com
Sat Jul 23 19:12:09 CEST 2011
Let say i have a square matrix and applied the 'vech' operator to stack the lower triangular elements into a vector:
> Mat <- matrix(1:25, 5)
> Mat
[,1] [,2] [,3] [,4] [,5]
[1,] 1 6 11 16 21
[2,] 2 7 12 17 22
[3,] 3 8 13 18 23
[4,] 4 9 14 19 24
[5,] 5 10 15 20 25
> Mat[lower.tri(Mat)]
[1] 2 3 4 5 8 9 10 14 15 20
Now, I want to reverse-work with the resulting matrix. Means, given a "correct" vector, I want to place the elements of this vector into the lower-triangular portion of some "correct" square matrix.
Would somebody help me to implement that?
Thanks,
More information about the R-help
mailing list