Serguei Kaniovski wrote:
> Hello
>
> I can construct a correlation matrix from an (ordered) vector of
> correlation coefficients as follows:
>
> x <- c(0.1,0.2,0.3,0.4,0.5)
> n <- length(x)
> cmat <- diag(rep(0.5,n))
> cmat[lower.tri(cmat,diag=0)] <- x
> cmat <- cmat+t(cmat)
>
> But how to do the reverse operation, i.e. produce x from cmat?

This comes close:

 cmat[lower.tri(cmat)]

It produces a vector of length 10 because x was recycled in your line 4.

Duncan Murdoch

______________________________________________
[email protected] mailing list
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