Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: simulate binary data based on probability

From   "Nick Cox" <>
To   <>
Subject   st: RE: simulate binary data based on probability
Date   Wed, 2 Jul 2003 14:26:10 +0100


> A problem in simulation torment me. Any suggestion is appreciated!
> I got a survey data (outcome: disease, yes/no), which is supposed to
> be too large in sample size. This could result in Type I
> Error. I try
> to solve this problem through simulating data.
> Based on the original data, I built a logistic model to obtain a
> fitted probability to each subject. And then, I want to simulate
> binary data for one particular health outcome (1 for yes
> and 0 for no)
> based on the fitted probability (from above step) using binomial
> probability distribution. But I don't know how to do this kind
> simulation is stata?

If I understand you correctly, this is the heart of
the matter:

Suppose probability of yes is 0.12345. Then

gen simulated = uniform() <= 0.12345

yields a variable with values 1 or 0 according
to whether random uniforms fall below or above
the stated threshold.


*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index