Hello

I am constructing a symmetric matrix with library "corpcor". In the
codes below, I am able to construct a symmetric matrix of order 3 and
4. However, the 5 x 5 matrix does not seem right? Help?

Thanks.


> library(corpcor)> r  <- 1:3> rr <- vec2sm(r, diag = F)> rr <- 
> rr[upper.tri(rr)]> r  <- vec2sm(rr, diag = F); diag(r) <- 1> r     [,1] [,2] 
> [,3]
[1,]    1    1    2
[2,]    1    1    3
[3,]    2    3    1> > r  <- 1:6> rr <- vec2sm(r, diag = F)> rr <-
rr[upper.tri(rr)]> r  <- vec2sm(rr, diag = F); diag(r) <- 1> r
[,1] [,2] [,3] [,4]
[1,]    1    1    2    4
[2,]    1    1    3    5
[3,]    2    3    1    6
[4,]    4    5    6    1> > r  <- 1:10> rr <- vec2sm(r, diag = F)> rr
<- rr[upper.tri(rr)]> r  <- vec2sm(rr, diag = F); diag(r) <- 1> r
[,1] [,2] [,3] [,4] [,5]
[1,]    1    1    2    5    3
[2,]    1    1    6    8    4
[3,]    2    6    1    7    9
[4,]    5    8    7    1   10
[5,]    3    4    9   10    1

>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to