this is a follow up to that question. i have been trying to generate
integers instead of numbers distributed between 0 and 1. Anyone knows
the procedure to that problem?
Sincerely,
ting
>>> [email protected] 03/09/05 8:19 PM >>>
Dear listers:
I am generating a random number with the goal of (randomly) assigning
children who report multiple races to a single race category for
purposes of analysis. I'd like to evenly distribute children across
single race categories. However, when I use uniform() to generate a
random number, I don't get an even split:
. gen r = uniform() if k_race == 801
(363374 missing values generated)
. su r
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
r | 2309 .4995691 .2914078 .0007709 .9993796
. gen byte k_race2 = .
(365683 missing values generated)
. replace k_race2 = 100 if r <= 0.5
(1151 real changes made)
. replace k_race2 = 200 if r > 0.5 & r <= 1
k_race2 was byte now int
(1158 real changes made)
I am puzzled. I would expect median = mean = 0.5 for a uniform number
defined over [0,1). This must be a simple, basic question, but neither
changing the - set seed -, changing the interval to [0,1], or changing
the observations selected seems to solve this problem. A search of
on-line help, the list archives and the Stata FAQs didn't give me much
insight either.
Can you help me figure out what I'm doing wrong?
Thanks,
Deb Garvey
******************************
Deborah Garvey, Ph.D.
Department of Economics
Kenna Hall
Santa Clara University
Santa Clara, CA 95053
408/554-5580
408/554-2331 (FAX)
[email protected]
http://lsb.scu.edu/~dgarvey
**********************************
This message scanned for viruses and SPAM by GWGuardian at SCU (MGW1)
*
* 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/
*
* 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/