[R] Generating a valid covariance matrix

davidr at rhotrading.com davidr at rhotrading.com
Fri Sep 26 20:42:15 CEST 2008


Depending on what you want your covariance matrices to be like, you
could form 
random symmetric matrices with positive diagonals and then use nearPD
{Matrix} 
to make them positive definite, but the resulting distribution of
covariance 
matrices would be hard to guess. And giving a diagonal matrix to
rwishart {bayesm} 
results in random matrices with non-zero correlations, so it's not so
hard.

-- David


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Robin Hankin
Sent: Friday, September 26, 2008 5:10 AM
To: megh700004 at yahoo.com
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Generating a valid covariance matrix

Megh

corr.matrix() in the 'emulator' package can calculate
P-D variance matrices using any of a  very broad
class of methods.


HTH

rksh

Megh Dal wrote:
> I want to generate a valid variance-covariance matrix. One way could
be to generate some random sample from multivariate normal distribution
and then calculate cov. matrix. Another way could be to sample from
wishart distribution itself. However both cases need a valid i.e. PD
covariance matrix. As I need to generate that covariance matrix only, I
am not interested those two methods. Can anyone suggest me some other
way out?
>
> Regards,
>
> ______________________________________________
> R-help at r-project.org 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.
>   


-- 
Robin K. S. Hankin
Senior Research Associate
Cambridge Centre for Climate Change Mitigation Research (4CMR)
Department of Land Economy
University of Cambridge
rksh1 at cam.ac.uk
01223-764877

______________________________________________
R-help at r-project.org 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.



More information about the R-help mailing list