Re: [R] generating symmetric matrices

2007-07-31 Thread Michael Dewey
At 16:29 30/07/2007, Gregory Gentlemen wrote: Douglas Bates [EMAIL PROTECTED] wrote: On 7/27/07, Gregory Gentlemen wrote: Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The

[R] generating symmetric matrices

2007-07-30 Thread Gregory Gentlemen
Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p - 6 Rmat - diag(p) dat.cor - rnorm(p*(p-1)/2) Rmat[outer(1:p, 1:p, )] - Rmat[outer(1:p, 1:p, )]

Re: [R] generating symmetric matrices

2007-07-30 Thread Benilton Carvalho
after dat.cor use: Rmat[lower.tri(Rmat)] - dat.cor Rmat - t(Rmat) Rmat[lower.tri(Rmat)] - dat.cor b On Jul 27, 2007, at 11:28 PM, Gregory Gentlemen wrote: Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of

Re: [R] generating symmetric matrices

2007-07-30 Thread Douglas Bates
On 7/27/07, Gregory Gentlemen [EMAIL PROTECTED] wrote: Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p - 6 Rmat - diag(p) dat.cor -

Re: [R] generating symmetric matrices

2007-07-30 Thread John Logsdon
Since a symmetric matrix must be square, the following code does it: X-5 MAT-matrix(rnorm(X*X),X,X) MAT-MAT+t(MAT) MAT [,1] [,2] [,3] [,4] [,5] [1,] 0.1084372 -1.7867366 -0.9620313 -1.0925719 -0.5902326 [2,] -1.7867366 -0.0462097 -1.2707656 0.6112664

Re: [R] generating symmetric matrices

2007-07-30 Thread Gregory Gentlemen
Douglas Bates [EMAIL PROTECTED] wrote: On 7/27/07, Gregory Gentlemen wrote: Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p - 6 Rmat -

Re: [R] generating symmetric matrices

2007-07-30 Thread Charles C. Berry
On Fri, 27 Jul 2007, Gregory Gentlemen wrote: Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p - 6 Rmat - diag(p) dat.cor -

Re: [R] generating symmetric matrices

2007-07-30 Thread Douglas Bates
On 7/30/07, Gregory Gentlemen [EMAIL PROTECTED] wrote: Douglas Bates [EMAIL PROTECTED] wrote: On 7/27/07, Gregory Gentlemen wrote: Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using

Re: [R] generating symmetric matrices

2007-07-30 Thread Bert Gunter
it. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gregory Gentlemen Sent: Friday, July 27, 2007 8:28 PM To: r-help@stat.math.ethz.ch Subject: [R] generating symmetric matrices Greetings, I have a seemingly simple

Re: [R] generating symmetric matrices

2007-07-30 Thread Cleber Borges
hello try ?upper.tri # example p - 6 Rmat - diag(p) dat.cor - rnorm(p*(p-1)/2) Rmat[upper.tri(Rmat)]- dat.cor Rmat[lower.tri(Rmat)]- dat.cor Cleber Borges Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a

Re: [R] generating symmetric matrices

2007-07-30 Thread Ted Harding
On 28-Jul-07 03:28:25, Gregory Gentlemen wrote: Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p - 6 Rmat - diag(p) dat.cor -

Re: [R] generating symmetric matrices

2007-07-30 Thread Ben Bolker
Gregory Gentlemen gregory_gentlemen at yahoo.ca writes: Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: [snip] p - 6 Rmat - diag(p) vals