Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: random numbers generator


From   "Cassio M. Turra" <cmturra@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: random numbers generator
Date   Sun, 6 May 2007 22:17:02 -0300

Terrific. Many thanks.

On 5/6/07, Maarten buis <maartenbuis@yahoo.co.uk> wrote:
--- "Cassio M. Turra" <cmturra@gmail.com> wrote:
> I need to input age of death for individuals between single years of
> age. Let's suppose that for the ages 20 to 25, I have the following
> distribution of ages of death among those who die (these are not real
> data).
>
> 20 0.40
> 21 0.20
> 22 0.15
> 23 0.20
> 24 0.05
>
> I need to draw random numbers based on this distribution.

gen ran = uniform()
gen agedeath = cond(ran<.4  , 20, /*
           */ cond(ran<.6  , 21, /*
           */ cond(ran<.75 , 22, /*
           */ cond(ran<.95 , 23, 24))))

For an explanation see:
http://www.stata.com/statalist/archive/2007-04/msg00906.html

Hope this helps,
Maarten



-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


     ___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


--
Cássio Maldonado Turra
Professor Adjunto
Departamento de Demografia / Cedeplar
Universidade Federal de Minas Gerais
turra@cedeplar.ufmg.br
55-31-3279-9183

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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   |   What's new   |   Site index