Re: [R] How to speed up a for() loop

2011-02-17 Thread Phil Spector
Simona - I don't think preallocating your random variables would make the code run any faster. A very simple change that would speed things up a little would be to replace simPD.vec[i]=length(R.vec[R.vec Dear all, Does anyone have any idea on how to speed up the for() loop below. Current

[R] How to speed up a for() loop

2011-02-17 Thread simona.costanzo
Dear all, Does anyone have any idea on how to speed up the for() loop below. Currently it takes approximately 2 minutes and 30 seconds. Because of the size of Nsim and N, simulating a multivariate normal (instead of simulating Nsim times a vector of N normal distributions) would require too much