Generating Random Variables with given correlations between pairs of them:
问题 I want to generate 2 continuous random variables Q1 , Q2 (quantitative traits, each are normal) and 2 binary random variables Z1 , Z2 (binary traits) with given pairwise correlations between all possible pairs of them. Say (Q1,Q2):0.23 (Q1,Z1):0.55 (Q1,Z2):0.45 (Q2,Z1):0.4 (Q2,Z2):0.5 (Z1,Z2):0.47 Please help me generate such data in R. 回答1: This is crude but might get you started in the right direction. library(copula) options(digits=3) probs <- c(0.5,0.5) corrs <- c(0.23,0.55,0.45,0.4,0.5,0