s-news
[Top] [All Lists]

Re: simulate correlation matrices

To: "S-news" <s-news@lists.biostat.wustl.edu>, <Willi.Weber@aventis.com>
Subject: Re: simulate correlation matrices
From: "Vahid Partovi Nia" <vahidpartovinia@yahoo.com>
Date: Tue, 26 Feb 2002 04:10:17 +0330
References: <D63B2E2DA19A974794F1DBBCE9CFBA35168D27@frasmxsusr14.pharma.aventis.com>
Hello Willi ,
I had the same problem .
It is easy to simulate if you know a little linear algebra & multivariate
statistics .

there is  a theorem in multivariate statistics which allow you to simulate :

if X (k*1) vector which has multivariate normal distribution with parameters
[MU(k*1), SIGMA(k*k)]

[[Which MU is the mean vector and SIGMA is variance - covariance matrix ]]


Theorem states that :

if A*X has a multivariate normal distribution mentioned above and A(j*k) is
a constant matrix (collection of linear combinations of X vector) then A*X
has
multivariate normal distribution with parameters (A*MU , A*SIGMA*A')
which A' is transpose matrix of A.

Your problem is a special case of this theorem :

Simulate X as normal distribution with parameters [0,I(k*k)] which I(k*k) is
an Identity matrix ,
maybe you couldn't find a procedure in S+ which simulates Multivariate
Normal .

It can be solved also by simulating k independent Normal(0.1) x's . [use
rnorm(n,mu,sigma) in S+]

then you should find Rho^0.5 which Rho is your desired correlation matrix ,
Square root of matrix can be found by spectal decomposition of matrix (see a
linear algebra book) , (I think is in enough to write  in S+ "rho^0.5")

Now using theorem above :
A=Rho^0.5
X multivariate normal distribution with parameters [0,I(k*k)]
A*X has multivariate normal distribution with parameters (0 , Rho)

AX is your desired vector of random normal variables

This theorem mentioned in below book , you can find it in most multivariate
statistics references .
I used :
Applied Multivariate Statistics - R.A.Johnson & D.W.Wichern -2nd edition
:page127

& just 1 question remains :

Is there another method for assessing desired correlation matrix without
multivariate normal distribution (for example iid uniform distribution
vector )?

I tried to answer it , but I found that there is not such a direct and
simple method mentioned above.

If you change normal distribution to another , you should change your method
for simulation .

and finally , If you had problem for this simulation in (theory or running
in S+) , I will be happy to help you .
my address is below

Best Wishes

Vahid.

------------------------------------------------------
Vahid Partovi Nia
B.Sc student of statistics ,
Ferdowsi University of Mashhad , Iran .

www.geocities.com/vahidpartovinia/
vahidpartovinia@yahoo.com
------------------------------------------------------

Attention : if you chose your desired correlation (rho) matrix positive
definit  _and_  symmetric , correlation matrix for x's is also positive
definite  _and_  symmetric and you won't have previous problems .




----- Original Message -----
From: <Willi.Weber@aventis.com>
To: <vograno@arbitrade.com>; <ezivot@u.washington.edu>;
<s-news@lists.biostat.wustl.edu>
Sent: Tuesday, February 26, 2002 11:24 AM
Subject: Re: [S] simulate correlation matrices


> 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
> --------------------------------------------------------------------
> 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







_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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