Statalist The Stata Listserver


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

Re: st: simulating data with a random binomial distribution


From   "Stas Kolenikov" <[email protected]>
To   [email protected]
Subject   Re: st: simulating data with a random binomial distribution
Date   Fri, 8 Sep 2006 15:47:24 -0500

On 9/8/06, Shawn Bauldry <[email protected]> wrote:
*** Set desired parameters
local b0 = 0.5
local b1 = 1.0
local b2 = 3.0
local b3 = -4.0

*** Generating population data of 10,000 cases
set obs 10000
set seed 1234 // just in case, and for good programming style

forvalues i = 1/3 {
        gen x`i' = uniform()
}

gen p1 = `b0' + `b1'*x1 + `b2'*x2 + `b3'*x3
gen p2 = exp(p1) / (1 + exp(p1))
gen byte outcome = ( uniform() < p2 )

--
Stas Kolenikov
http://stas.kolenikov.name
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index