[R] factor analysis backwards
Chuck Cleland
ccleland at optonline.net
Wed Apr 12 15:58:42 CEST 2006
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 purpose
I'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
More information about the R-help
mailing list