Hallo everybody, I'm new in r and I"ll appreciate some help!
I have a matrix of nrow=30 and ncoll=54,and I would like to generate 50 simulations with tha same size of the matrix!!!That is to say that I want to generate 50 matrices -for my 50 simulations - with the same dimensions! I took my 1st matrix according to the formula that I want to implement: D<-mean_m + U_i*mat_DELTA mean_m:vector U_I:vector mat_Delta:matrix(54,30) Here is the loop: #Define Simulations(IS) #Define Time Step(IT) vec_IS<-c(1:50) vec_IT<-c(1:30) mat_delta<-matrix(nrow=54, ncol=30) mat_DELTA<-matrix(nrow=54, ncol=30) mat_Yr_m<-matrix(nrow=54, ncol=30) D<-matrix(nrow=30, ncol=54) DELTA<-(matrix(nrow=30,ncol=54))*50 for (i in 1:length(vec_IS)){ for (j in 1:length(vec_IT)){ Yr_m<-rnorm(54,m=0,sd=1) mat_Yr_m[,j]<-Yr_m delta_i<-lower_m%*%mat_Yr_m[,j] mat_delta[,j]<-as.vector(delta_i) } DELTA_1<-mat_delta[,1] DELTA_2<-mat_delta[,2]-a_1*mat_delta[,1] for (t in 3:length(vec_IT)){ mat_DELTA[,t]<-mat_delta[,t] - a_1*mat_delta[,t-1] - a_2*mat_delta[,t-2] } mat_DELTA[,1]<-DELTA_1 mat_DELTA[,2]<-DELTA_2 for (k in 1:length(nmesh)){ mean_m<-as.numeric(vec_mean_col) DELTA<-U_i*mat_DELTA D<-mean_m + t(DELTA) } } I want to implement this formula for 50 simulations! any idea? Thanks a lot! [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel