[R] R-help
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Jan 27 16:50:43 CET 2012
On Fri, Jan 27, 2012 at 9:49 AM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> Another way, which I believe will be a little more memory efficient
> and time inefficient, though that might vary by machine, would be to
> use replicate:
>
> library(MASS)
> set.seed(123)
> m <- replicate(1000, coef(fitdistr(rweibull(50, 0.8, 2), "weibull")))
> summary(t(m)) # Need to transpose here (or you could do it in the line
> above, but it's already crowded)
>
> I haven't tested my efficiency claims, but I'm pretty sure you gain on
> the memory end because it runs each simulation sequentially and only
> stores results, and you loose on the time end because you wind up
> calling rweibull() 1000 times instead of once. If you are leaning
> heavily on your memory bounds though, the time thing might be moot due
> to paging effects.
>
I timed them and they took about the same amount of time so I think
your replicate version is better since its slightly simpler although I
would use t(replicate(...)) even though it does not look as nice as
delaying the t to the next statement so that the object, m, that is
produced is in the standard orientation with cases in rows.
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list