Re: [R] set seed for random draws

2011-11-05 Thread Md Desa, Zairul Nor Deana Binti
Thank you everybody for the helpful advices. Basically, I try to figure out why I get different numbers as there are more than one seed for a loop within a loop. Well, I guest I got it now. Because every time random seed is called or specified it'll output different random numbers, as it's requ

[R] set seed for random draws

2011-11-04 Thread Md Desa, Zairul Nor Deana Binti
Hello, all! I need help on these two problems: 1) If I want to randomly draw numbers from standard normal (or other distributions) in loops e.g.: ty=0; ks=0 for (i in 1:5) { set.seed(14537+i) k<-rnorm(1) ks[i]<-.3*k+.9 if (ty==0) { while ((ks<.2)||(ks>

Re: [R] Create a matrix with increment and element with zero subscript

2011-10-25 Thread Md Desa, Zairul Nor Deana Binti
anks again! Deana PhD Candidate On Oct 24, 2011, at 19:02, "David Winsemius" wrote: > > On Oct 24, 2011, at 7:23 PM, Md Desa, Zairul Nor Deana Binti wrote: > >> Hello, >> Does anyone knows how to deal with zero subscript in R. I have this code: >> for (i in

[R] Create a matrix with increment and element with zero subscript

2011-10-24 Thread Md Desa, Zairul Nor Deana Binti
Hello, Does anyone knows how to deal with zero subscript in R. I have this code: for (i in 1:nitems){ + for (j in 1:ncat-1) { + draw<-matrix(rnorm(nitems*(ncat-1),seed1,seed2),nitems,(ncat-1)) + d<-( sigma_d*draw ) + mu_d + draw<-matrix(rtnorm((nitems*(ncat-1)