Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: How to generate binary y?
From
Bryan Griffin <[email protected]>
To
[email protected]
Subject
st: How to generate binary y?
Date
Fri, 4 May 2012 10:15:15 -0400
Here's some code I used in a do file to create clustered data for
analysis with xtlogit. Perhaps you can use some of this as a basis for
generating binary Y.
set more off
set obs 500
generate float z1= invnorm(uniform())
generate n = 5
generate id_2 = _n
expand n
bysort id_2: gen id_1 = _n
generate float u0j= invnorm(uniform())*1
generate float x1= invnorm(uniform())
generate y = 1 + 1*x1 + 1*z1 + u0j
generate p = exp(y)/(1+exp(y))
generate binary_y = uniform()<=p
iis id_2
xtlogit binary_y x1 z1, re
Bryan Griffin
E-Mail: [email protected]
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/