1

I would like to do a Monte Carlo simulation related to this post: How to predict the degree to which an extraneous variable will attenuate a correlation?

I need to generate a dataset with a Pearson r of .25 between order of grading a test and the test grade. One variable will have integer numbers as values (in my case, the counting numbers between 1 and 150.) The other variable will be continuous and preferably normal.

In other words, I would like to create a dataset with a new variable with a specified correlation with the counting numbers 1, 2, 3 ... 150.

Joel W.
  • 3,096
  • 3
  • 31
  • 45
  • Because $R^2$ determines the correlation up to sign, and the sign of the correlation is easily reversed (negate all values of the Normal variable), every possible solution is described, with code, at https://stats.stackexchange.com/questions/152028. – whuber Jan 17 '20 at 03:41
  • @whuber The links you provided are interesting but some are over my head. I would like to create a dataset with a new variable with a specified correlation with the counting numbers 1, 2, 3 ... 150. – Joel W. Jan 17 '20 at 16:01
  • That link gives working code: doesn't that comply with "create a dataset"?? – whuber Jan 17 '20 at 17:30
  • @whuber The R is a difficult for a non-R user to follow and replicate in another software package. – Joel W. Jan 17 '20 at 17:33
  • 1
    Unfortunately, we aren't a software-porting site. Once we have presented a full solution, the problems of implementing it on some computing platform are outside our purview. For that reason we do insist that solution be presented in a software-independent way whenever possible, but I believe the linked thread does that, too. – whuber Jan 17 '20 at 17:36

0 Answers0