I would like to simulate the following in R. Let X be a random variable that takes values {0, 1, 2} and Y,Z two random variables of any continuous distribution:
How to generate X, Y and Z so that the Pearson correlation between Y and Z is very high (e.g. r = 0.8), while their respective correlation with X is very different?.
In other words, which are the X, Y and Z that minimize cor(X,Y) and cor(X,Z), given that cor(Y,Z) = r, with r relatively large?
how to generate not only two (Y, Z) but k variables (Y_1, Y_2, ..., Y_k) that fulfill the previous (they have a correlation matrix with non-diagonal elements = r, with r very high), but they have very different correlations with X).?
1-2. Y~N(0,1), Z~N(Y,0), X = [Z<Y] + [Y<0], [.] = Iverson bracket In R:
I'll leave 3. as an exercise.