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

>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. 1. What is the reason behind the use of the linear predictor (-xb-) to obtain 'index' values? 2. Why the -uniform()- to generate random numbers? I know it's a latent LHS variable, but don't we want 'deterministic' results? 3. What 'Stata variables' do you mean as vlaues for coefficients? Two days ago, Nick Cox suggested a similar approach for -mlogit- (comments added): qui forval i = 1/`e(k_cat)' { predict ypb_`i', outcome(`i') xb /* NOTE -xb- ! */ replace ypb_`i' = exp(ypb_`i') } Are the Al's and Nick's approach identical (apart from different amount of outcomes)? For any clarifications I would be grateful, Daniel -----Original Message----- From: Sherry Weitzen [mailto:Sherry_Weitzen@brown.edu] 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: Sherry_Weitzen@Brown.edu * * 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/ * * 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/

- Prev by Date:
**st: AW: RE: simulating data ( => logit case)** - Next by Date:
**Re: st: AW: RE: simulating data ( => logit case)** - Previous by thread:
**st: RE: simulating data** - Next by thread:
**st: gauss and stata** - Index(es):

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