Dimitri Liakhovitski
2007-May-20 01:21 UTC
[R] creating a multivariate set of variables with given intercorrelations
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
Adaikalavan Ramasamy
2007-May-20 02:40 UTC
[R] creating a multivariate set of variables with given intercorrelations
I presume you want to generate normally or t-distributed values ? If so either have a look mvrnorm in the MASS package or the mvtnorm package. Dimitri Liakhovitski wrote:> 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. > > >
Mendiburu, Felipe (CIP)
2007-May-20 03:17 UTC
[R] creating a multivariate set of variables with givenintercorrelations
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.