Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Successive rounds of a simulation become slower and slower


From   Joerg Luedicke <joerg.luedicke@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Successive rounds of a simulation become slower and slower
Date   Wed, 26 Oct 2011 16:59:01 -0400

On Wed, Oct 26, 2011 at 1:50 PM, Joerg Luedicke
<joerg.luedicke@gmail.com> wrote:
> If every simulation run really does the same thing, then the
> time increase is linear.


Due to the non-absence of procrastination tendencies on my end, here
is some actual evidence, supporting the above claim:

/***********************************/
capture program drop simtime
program define simtime, rclass
clear
timer clear 1
timer on 1
qui set obs 1000
qui gen float y=rnormal()
forval i=1/20 {
	qui gen float x`i'=rnormal()
}
qui reg y x*
timer off 1
qui timer list 1
return scalar t=r(t1)
end

simulate time=r(t), reps(1000) saving(simtime1000, replace): simtime

gen run=_n
gen cumtime=time
replace cumtime=cumtime+cumtime[_n-1] if _n>1
scatter cumtime run
/***********************************/

Joerg
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index