[R] Generating artificial datasets with a specific correlation coefficient.

John Vokey vokey at uleth.ca
Thu Jun 14 05:14:42 CEST 2007


Jim,
   Try here: <http://www.sitmo.com/doc/ 
Generating_Correlated_Random_Numbers>; the example code is in matlab,  
but it is trivial to translate to R.  Note, if you use principal  
components as the source vectors (thanks to Jason Tangen for the  
suggestion), the correlations between the resulting vectors will be  
exactly the specified r-values.

On 13-Jun-07, at 4:00 AM, r-help-request at stat.math.ethz.ch wrote:
> I need to create artificial datasets with specific correlation
> coefficients (i.e. a dataset that returns r = 0.30, etc.) as examples
> for a lab I am teaching this summer.  Is there a way to do that in R?

--
Please avoid sending me Word or PowerPoint attachments.
See <http://www.gnu.org/philosophy/no-word-attachments.html>

-Dr. John R. Vokey



More information about the R-help mailing list