I am trying to do some simulations with built function in r mvrnorm
.
I used this function three times in the same code.
Is it enough to put set.seed at the beginning or I have to write it each time before mvrnorm
.
of course, I want the result to be reducible and to replicate this simulation 10,50 and 100 times.
The following is my code
set.seed(30)
mu1<-cbind(matrix(0,nrow=1,ncol=5),t(c(1)))
mu2<-matrix(0,nrow=1,ncol=6)
Sigma<-matrix(1,nrow=p,ncol=6)+diag(6)*0.1
M1=mvrnorm(50,mu1,Sigma)
M2<-mvrnorm(50,mu2,Sigma)
M11<-mvrnorm(n,rep(0,10),diag(10)+matrix(0.3,nrow=10,ncol=10))
Data=data.frame(cbind(rbind(M1,M2),M11))