Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

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

From   "Lacy,Michael" <>
To   "" <>
Subject   Re: st: Successive rounds of a simulation become slower and slower
Date   Sat, 29 Oct 2011 14:03:45 +0000

...Left out my report while previously trying to close this thread; sorry for my error.

On Wed, Oct 26, 2011 at 12:34 PM, 
I wrote:
> Successive rounds of a simulation I'm doing become progressively slower, so much so as to make continuing impractical. I'd like to figure out why this is happening
> and cure it. The first round might take 2 minutes, then 5 minutes for the next, then 15, etc. Each round *should* take the same amount of time, since the same estimation process  is being performed on similar data at each round.

snip, snip...

>Date: Wed, 26 Oct 2011 13:50:01 -0400
>From: Joerg Luedicke <>
>Subject: Re: st: Successive rounds of a simulation become slower and slower

>I don't think this can be answered without you showing your actual
>code. If every simulation run really does the same thing, then the
>time increase is linear. Therefore, something must be wrong with your
>code and I suspect it has to do with your using several loops and the
>stuff that is included/not included in each loop. But as I said, this
>is not answerable without seeing what is actually going on.

>Also, consider using Stata's -simulate-.


Thanks to comments from Joerg and Alan Feiveson, I was prompted to think in the right direction to find the problem:  In the midst of the loop to repeat the estimation process within each round of the simulation, I was instantiating a temporary matrix, but not dropping it.  While this matrix was not large (say 20 items), a new instance was being created at each of 1,000 repetitions.   This should not have caused a memory problem (20,000 floats is not huge), so my guess is that the existence of 1,000 temporary matrices led to some kind of overhead issue.


Mike Lacy
Colorado State University
Fort Collins CO 80523-1784

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index