I have a variable with a given distribution (normale in my below example).
set.seed(32)
var1 = rnorm(100,mean=0,sd=1)
I want to create a variable (var2) that is correlated to var1 with a linear correlation coefficient (roughly or exactly) equals to "Corr". The slope of regression between var1 and var2 should (rougly or exactly) equals 1.
Corr = 0.3
How can I achieve this?
I wanted to do something like this:
decorelation = rnorm(100,mean=0,sd=1-Corr)
var2 = var1 + decorelation
But of course when running:
cor(var1,var2)
The result is not close to Corr!