0

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))
jeza
  • 299
  • 1
  • 4
  • 21
  • @李哲源, yes I know the difference. I mentioned that because I do not want to have the same results of the replication say for example 30,30,30,30,... – jeza Aug 27 '18 at 15:50
  • @李哲源, ok thanks, but why I do not need to set seed before each mvrnorm. – jeza Aug 27 '18 at 15:53
  • @李哲源, you are a very kind person. Many thanks. – jeza Aug 27 '18 at 16:02

0 Answers0