## Generate desired correlation structure
corr.mat <- cbind(c(1, 0.7),c(0.7, 1))
## Generate 10 observations of 2 exogenous variables
X <- makedata.corr(n = 10, k = 2, CORR = corr.mat)
cor(X) # not exact values of corr.mat
## Same structure applied to a sample
X <- makedata.corr(n = 10, k = 2, CORR = corr.mat, sample = TRUE)
cor(X) # exact values of corr.mat
Run the code above in your browser using DataLab