search for: drawmat

Displaying 1 result from an estimated 1 matches for "drawmat".

Did you mean: drawat
2004 May 19
0
R Optimization 101 for R Newcomers: An extended example
...le it yourself. To use apply, the simple idea is just to make up a matrix with nsim columns with enough rows so that each column contains "enough" random draws from mydat to sum to more than K. Let's say that we decide M rows will do it. Then the code for the whole simulation is: drawmat<-matrix(sample(mydat,M*nsim,rep=TRUE),ncol=nsim) drawmat <-apply(drawmat,2,cumsum)<K result<- colSums(drawmat)+1 The first statement generates the matrix of bootstrap samples, while the second and third use the same trick as previously to get the number of rows needed for each...