Hello! How can I do a factor analysis backwards to get an arbitrary covarianz matrix out of an arbitrary number of generated random variables that have a correlation near zero. Or the same question shorter: How to generate random variables that have a spezial correlation pattern. I would like to be able to do this to generate arbitrary data structures for simulation purpose sincerely stefan
Stefan Premke wrote:> Hello! > How can I do a factor analysis backwards to get an arbitrary covarianz > matrix out of an arbitrary number of generated random variables that > have a correlation near zero. Or the same question shorter: How to > generate random variables that have a spezial correlation pattern. > I would like to be able to do this to generate arbitrary data structures > for simulation purposeI'm not sure what you mean by "arbitrary", but have a look at mvrnorm() in packages MASS. For example: library(MASS) cor(mvrnorm(n = 300, mu=rep(0,4), Sigma=diag(4))) [,1] [,2] [,3] [,4] [1,] 1.00000000 -0.00524425 -0.04464669 -0.01223580 [2,] -0.00524425 1.00000000 -0.08920532 -0.10521937 [3,] -0.04464669 -0.08920532 1.00000000 -0.05316380 [4,] -0.01223580 -0.10521937 -0.05316380 1.00000000> sincerely > stefan > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894
RSiteSearch("simulate specified covariance") will bring you to mvrnorm() in MASS. Please try to use R's built-in search capabilities first before posting. I realize that keywords can be hard to guess, but you may find that when the hits are **not** what you want, you need to refine your question more, as described in the posting guide (have you read it?) -- Bert Gunter -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Stefan Premke Sent: Wednesday, April 12, 2006 6:52 AM To: r-help at stat.math.ethz.ch Subject: [R] factor analysis backwards Hello! How can I do a factor analysis backwards to get an arbitrary covarianz matrix out of an arbitrary number of generated random variables that have a correlation near zero. Or the same question shorter: How to generate random variables that have a spezial correlation pattern. I would like to be able to do this to generate arbitrary data structures for simulation purpose sincerely stefan ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html