Create variables with pre-specified correlation I have a vector: a<-rnorm(100)
I would like to create 5 variables that are correlated with a to a different extent.
For example each of the 5 variables should have a correlation of .5, .6, .7, .8, .9 with a respectively
How can this be done?
 A: As it is, there are many ways to formulate (and thus solve) your problem. 
you are looking for the symmetric, psd matrix $A$ with $A_{1\cdot}=\{1,0.9,0.8,0.7,0.6,0.5\}$ and $A_{ii}=1,\;i=1,\ldots,6$.  There are many matrices satisfying these requirements. To pick one we need to add some more criterion/constraints. For example: if we add the criterion that we also want $|A|$ to be smallest and all the entries of $A\setminus \{A_{ii},A_{1\cdot}\}$ to be equal to some constant $\nu$. This is now a convex problem with a unique solution. In R you would write solve it as:
fx01<-function(nu,FixedRow){
    p<-lenght(FixedRow)
    a1<-matrix(nu,p,p)
    diag(a1)<-1
    a1[1,]<-a1[,1]<-FixedRow
    -det(a1)
}


FixedRow<-c(1,.9,.8,.7,.6,.5)
a1<-optimize(fx01,interval=c(-1,1),FixedRow=FixedRow)

and the value $\nu\approx0.6$, yielding the matrix:
nu<-a1$min
a2<-matrix(nu,6,6)
diag(a2)<-1
a2[1,]<-a2[,1]<-c(1,.9,.8,.7,.6,.5)


     a   b    c    d    e    f
a  1.0  0.9  0.8  0.7  0.6  0.5
b  0.9  1.0  0.6  0.6  0.6  0.6
c  0.8  0.6  1.0  0.6  0.6  0.6
d  0.7  0.6  0.6  1.0  0.6  0.6
e  0.6  0.6  0.6  0.6  1.0  0.6
f  0.5  0.6  0.6  0.6  0.6  1.0

which satisfies your requirements. Then, to actually generate your matrix of variables simply do:
library("MASS")
set.seed(123)
X<-mvrnorm(100,rep(0,6),a2,empirical=TRUE)
cor(X)

and you can check that, for example 
cor(X[,1],X[,2])
returns 0.9.
