Sherry
Suppose you have a data set where x1, ..,xp are your independent variables
(including dummies for treatment(s)). Then for logistic regression
coefficients c0, c1, c2,..,cp issue the following commands:
gen z = c0 + c1*x1 +.... + cp*xp
gen p = exp(x)/(1+exp(z))
gen y=uniform()<=p
z is the "xb", the linear predictor
p is the probability that y=1
The last statement generates random values of y that are 0 with probability
1-p and 1 with probability p.
It's up to you to set up the data set with the x's and to specify the values
of the coefficients (the c's). They can be eiher Stata variables (a waste of
space) or scalars or local macros.
Al Feiveson
-----Original Message-----
From: Sherry Weitzen [mailto:[email protected]]
Sent: Thursday, November 21, 2002 3:56 PM
To: STATALIST
Subject: st: simulating data
I feel very naive.. I'd like to simulate data from a logistic model with
several independent variables (including a treatment variable and several
confounders). I have no idea where to start. Please advise. thank you.
Sherry Weitzen
Department of Community Health
Brown University, Box G
Providence RI 02912
401-863-9215
Reply to: [email protected]
*
* 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/