[R] how to make simulation faster

stats12 skarmv at gmail.com
Fri Oct 26 15:37:45 CEST 2012


Thank you. I tried Rprof and looks like aggregate function I am using is one
of the functions that takes most of the time. What is the difference between
self time and total time?

$by.total
                       total.time total.pct self.time self.pct
f                          925.92     99.98      5.16     0.56
<Anonymous>                925.92     99.98      0.06     0.01
nlm                        925.92     99.98      0.00     0.00
aggregate                  885.66     95.64      0.28     0.03
aggregate.default          885.38     95.61      0.02     0.00
aggregate.data.frame       885.34     95.60     12.54     1.35
lapply                     817.06     88.23    183.76    19.84
FUN                        814.48     87.95     53.50     5.78
split                      425.06     45.90      4.50     0.49
split.default              420.56     45.41     14.16     1.53
factor                     408.84     44.15    347.12    37.48
unique                     235.32     25.41     19.38     2.09
sapply                     202.60     21.88      1.70     0.18
unlist                     181.40     19.59    132.28    14.28
simplify2array             148.70     16.06      1.10     0.12
[[<-                        41.24      4.45      1.62     0.17
[[<-.data.frame             39.62      4.28     31.42     3.39
^                           26.18      2.83     26.18     2.83



jholtman wrote
> use Rprof to profile your code to determine where time is being spent. 
> This might tell you where to concentrate your effort.
> 
> Sent from my iPad
> 
> On Oct 25, 2012, at 23:23, stats12 <

> skarmv@

> > wrote:
> 
>> Dear R users,
>> 
>> I need to run 1000 simulations to find maximum likelihood estimates.  I
>> print my output as a vector. However, it is taking too long. I am running
>> 50
>> simulations at a time and it is taking me 30 minutes. Once I tried to run
>> 200 simulations at once, after 2 hours I stopped it and saw that only
>> about
>> 40 of them are simulated in those 2 hours. Is there any way to make my
>> simulations faster? (I can post my code if needed, I'm just looking for
>> general ideas here). Thank you in advance. 
>> 
>> 
>> 
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/how-to-make-simulation-faster-tp4647492.html
>> Sent from the R help mailing list archive at Nabble.com.
>> 
>> ______________________________________________
>> 

> R-help@

>  mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________

> R-help@

>  mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.





--
View this message in context: http://r.789695.n4.nabble.com/how-to-make-simulation-faster-tp4647492p4647544.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list