[R] generate correlated dataset

Spencer Graves spencer.graves at pdf.com
Sat May 10 00:48:12 CEST 2003


	  To get a target correlation between observations in different 
clusters, consider the following:

	  var(Y) = E(var(Y|X))+var(E(Y|X)).

	  The correlation between observations in a give cluster is determined 
by E(var(Y|X)).  To get a target correction between clusters, select 
E(Y|X)) so var(Y) is what you want.

hope this helps.  spencer graves

Huntsinger, Reid wrote:
> You could use mvrnorm once for each cluster, with a different mean vector
> each time (if you mean clusters in that sense.) 
> 
> You could draw the number of observations in a cluster randomly if that's
> important.
> 
> Reid Huntsinger
> 
> -----Original Message-----
> From: ge yreyt [mailto:tothri2000 at yahoo.ca] 
> Sent: Friday, May 09, 2003 5:02 PM
> To: r-help
> Subject: [R] generate correlated dataset
> 
> 
> Hi,I want to generate a dataset, which have more than one clusters (say 2)
> and the elements in each cluster have high correlation (say 0.85)
> andelements among different clusters have low (say 0.1) or zero
> correlation.The correlation structure of final dataset should have a
> block-diagonal structure, that likes  0.85 0.85 .. 0.85 0 0 0 0 ...0 0 0...0
> 0 0 .......................................................0.85 0.85  ..
> 0.85 0 0 0 0...0 0 0 ...0 0 0 0 0 0 0 000 0000 0.85 0.85 0.85 ....
> 0.85.........................................................0 0 0 0 0......
> 0 0 0.85 0.85 .............0.85 for each block (cluster), I can use mvrnorm
> command to generate data,but the key problem is I do not know how to
> generate data which have 0correlation when elements are among different
> clusters???? Thank you very much for your help!!! pin   
> 
> 
> ---------------------------------
> Post your free ad now! Yahoo! Canada Personals
> 
> 	[[alternate HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 
> ------------------------------------------------------------------------------
> Notice: This e-mail message, together with any attachments, cont... {{dropped}}
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list