I am trying to simulate a vector that is correlated to a few other vectors. I figured out the code for simulating a vector correlated to one other vector, but can't figure out how to simulate it with correlations to multiple other vectors:
Here is my code:
library(faux)
p4<-rnorm_pre(data$p1, mu = 0, sd = 10, r = 0.4, empirical = FALSE)
What I would like to do is somehow identify multiple vectors for the simulated trait to be correlated to. Im not sure if this library is the best to use
My data look like
ID p1 p2 p3
1 0.25 0.30 0.02
2 0.05 0.67 0.18
3 0.09 0.31 0.38
4 0.55 0.87 0.21
5 0.25 0.64 0.01
And I would like to add another column called p4 that is the vector of simulated data, which is correlated to p1 and p3.
Any suggestions are much appreciated.