0

I want to generate 5 columns with data 0 and 1. I want to have a correlation coefficient of 0.70 between individual columns.

I understand we could do it with the mvrnorm function in the MASS package as explained already Generate two variables with precise pre-specified correlation

But this does not generate data between 0 and 1. I wonder if I have missed something. It is very good to demonstrate it using R codes.

User20100
  • 121
  • 5
  • I would be grateful if you could advise me for downvoting? I am searching and working hard to find out a solution, but unsuccessful. Your help very much appreciated. – User20100 Jan 05 '20 at 12:59
  • 2
    I don't know the reason for the downvote. Do you want correlated vectors of purely $0$'s & $1$'s, or do you want continuous values (w/ some distribution) that fall in the interval $(0,1)$? – gung - Reinstate Monica Jan 05 '20 at 20:12
  • Many thanks for your message, @gung-Reinstate Monica. I want only 'purely 0's and 1's". – User20100 Jan 05 '20 at 20:20
  • Do you have a specified base rate? It will be easiest if you have ~50% 1's, but can be possible w/ other base rates. How many values do you want? Again, it gets harder w/ fewer rows. – gung - Reinstate Monica Jan 05 '20 at 20:25
  • Yes, 50% is great. I want to have a sample size of 200 – User20100 Jan 05 '20 at 20:27

0 Answers0