[R] creating a multivariate set of variables with givenintercorrelations

Mendiburu, Felipe (CIP) F.MENDIBURU at CGIAR.ORG
Sun May 20 05:17:40 CEST 2007


Dear Dimitri,
 
if you wish single the correlations, can use the following script:
 
a<-1:10
b<- rnorm(10)
c<- rbinom(10,8,0.3)
d<- rpois(10,8)
corr<-cor( cbind(a,b,c,d) )
round(as.dist(corr),2) # or only as.dist(corr)
      a      b      c
b  0.07            
c  0.19 -0.26      
d -0.16 -0.13 -0.41


regards,
 
Felipe

Hi!
I was wondering if there is a package in R that allows one to create a
multivariate data set with pre-specified intercorrelations among
variables, e.g., a set of 4 variables (with a length of N each), such
that the correlations between variables are:

     a     b     c     d
a   1     r1    r2    r3
b          1     r4    r5
c                 1     r6
d                         1

Thank you very much!
Dimitri Liakhovitski

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list