s-news
[Top] [All Lists]

Re: simulate correlation matrices

To: vograno@arbitrade.com, ezivot@u.washington.edu, s-news@lists.biostat.wustl.edu
Subject: Re: simulate correlation matrices
From: Willi.Weber@aventis.com
Date: Tue, 26 Feb 2002 08:54:15 +0100
I thought so far, that a covariance matrix is symmetric to the diagonal
axis?
I tried:
x <- matrix(rnorm(5*5), ncol=5)
> t(x)%%x
           [,1]        [,2]        [,3]        [,4]       [,5] 
[1,]  0.0000000 -0.15417309  0.03567755  0.61815453  1.3748462
[2,] -0.0895276  0.00000000  0.20452335 -0.16291966 -0.6726954
[3,] -0.4599585  0.02824674  0.00000000 -0.05002809  0.2847527
[4,] -0.2125452 -0.73217427 -0.11275733  0.00000000  0.4920405
[5,]  0.3828471  0.10637537 -0.07138546  0.05963281  0.0000000

I may add t(x)%%x + diag(nrow(x))*sd*sd to get a full covariance matrix, but
would like to mirror the lower triangle matrix to the upper triangle matrix
before calculating the correlation matrix.
Any help?

Willi Weber, MD PhD
> ---------------------------------------------
> Specialist in Clinical Pharmacology
> Head of Population PK/PD
> Aventis Pharma Deutschland
> Drug Innovation & Approval
> Lead Optimization / DMPK
> Building H840, Room 451
> D-65926 Frankfurt am Main
> ---------------------------------------------
> Phone: ++49 69 305 / 15485
> ---------------------------------------------
> 



-----Original Message-----
From: Vadim Ogranovich [mailto:vograno@arbitrade.com]
Sent: Tuesday, February 26, 2002 3:56 AM
To: 'Eric Zivot'; S-News
Subject: Re: [S] simulate correlation matrices


Here is one possible way.

You can first generate a positive semi-definite matrix of covariances, cov,
and then convert it to the correlation matrix: cor[i,j] =
cov[i,j]/sqrt(cov[i,i]*cov[j,j]). You can use ?outer function to do it
efficiently.

In turn, the covariance matrix can, for example, be generated as
x <- matrix(rnorm(5*5), ncol=5)
cov <- t(x) %*% x

P.S. Note that non-negative determinant is a necessary, but not sufficient,
condition for a matrix to be a covariance matrix. You need a stronger
property of being semi-definite

-----Original Message-----
From: Eric Zivot [mailto:ezivot@u.washington.edu]
Sent: Monday, February 25, 2002 6:02 PM
To: S-News
Subject: [S] simulate correlation matrices


I am trying to simulate random 5 x 5 correlation matrices and I am getting
negative determinants for some of the correlation matrices. Apparently, my
method is not working. Does anyone have a reliable method for generating
valid arbitrary correlation matrices? thanks, ez

Eric Zivot
Associate Professor
Department of Economics
Box 353330
University of Washington
(206) 543-6715
http://faculty.washington.edu/ezivot
http://myprofile.cos.com/zivote47

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news

-------------------------------------------------- 
DISCLAIMER 
This e-mail, and any attachments thereto, is intended only for use by the
addressee(s) named herein and may contain legally privileged and/or
confidential information.  If you are not the intended recipient of this
e-mail, you are hereby notified that any dissemination, distribution or
copying of this e-mail, and any attachments thereto, is strictly prohibited.
If you have received this e-mail in error, please immediately notify me and
permanently delete the original and any copy of any e-mail and any printout
thereof. 

E-mail transmission cannot be guaranteed to be secure or error-free.  The
sender therefore does not accept liability for any errors or omissions in
the contents of this message which arise as a result of e-mail transmission.

NOTICE REGARDING PRIVACY AND CONFIDENTIALITY 

Knight Trading Group may, at its discretion, monitor and review the content
of all e-mail communications. 

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>