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

From: John Vokey <vokey_at_uleth.ca>
Date: Wed, 13 Jun 2007 21:14:42 -0600

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

______________________________________________
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.
Received on Thu 14 Jun 2007 - 03:22:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Jun 2007 - 05:31:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.