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]

From |
Stephen Cranney <scranney@sas.upenn.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Terminating a loop when a certain value is reached. |

Date |
Wed, 3 Apr 2013 07:45:05 -0400 |

Thank you Maarten. I think that, because some demographic events are by their nature sequential (e.g. post-partum infertility always needs to follow a birth so that the mother isn't pregnant twice in two months), that for certain probablistic microsimulations there's no way around looping over observations. However, for most of my simulation purposes, the slides you present are quite helpful (and eminently comprehensible). Thanks again, Stephen On Tue, Apr 2, 2013 at 4:31 AM, Maarten Buis <maartenlbuis@gmail.com> wrote: > On Mon, Apr 1, 2013 at 8:26 PM, Stephen Cranney wrote: >> Basically, I'm >> trying to make a microsimulation program in Stata because the other >> microsimulation programs are very technical and require sophisticated >> programming knowledge if you want to customize them to suit your >> needs, whereas a microsimulation program in Stata would be much more >> accessible and customizable. Hence my interest in keeping the code in >> Stata, even though alternative coding languages would be more >> efficient overall. > > Loops in such simulations in Stata are often unnecessary. Not only are > the unnecessary, they often make your code more complex than it needs > to be and are thus a source of error (as you have noticed). The magic > commands/prefixes for avoiding such loops in Stata are -by- and > -expand-. If the purpose of this excercise is to make use of the > simplicity of the Stata language, then you really need to make heavy > use of these commands to avoid loops. Here is a presentation on how to > create such demographic micro simulations without looping in Stata. > > <http://www.maartenbuis.nl/presentations/konstanz11.pdf> > > Hope this helps, > Maarten > > --------------------------------- > Maarten L. Buis > WZB > Reichpietschufer 50 > 10785 Berlin > Germany > > http://www.maartenbuis.nl > --------------------------------- > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ -- Stephen Cranney PhD Candidate Graduate Group in Demography University of Pennsylvania * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Terminating a loop when a certain value is reached.***From:*Stephen Cranney <scranney@sas.upenn.edu>

**Re: st: Terminating a loop when a certain value is reached.***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Terminating a loop when a certain value is reached.***From:*Stephen Cranney <scranney@sas.upenn.edu>

**Re: st: Terminating a loop when a certain value is reached.***From:*njcoxstata@gmail.com

**Re: st: Terminating a loop when a certain value is reached.***From:*Stephen Cranney <scranney@sas.upenn.edu>

**Re: st: Terminating a loop when a certain value is reached.***From:*Maarten Buis <maartenlbuis@gmail.com>

- Prev by Date:
**Re: st: xtlogit: panel data transformation's recast to double makes model incomputable** - Next by Date:
**Re: st: xtlogit: panel data transformation's recast to double makes model incomputable** - Previous by thread:
**Re: st: Terminating a loop when a certain value is reached.** - Next by thread:
**Re: st: Terminating a loop when a certain value is reached.** - Index(es):