Statalist The Stata Listserver


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

Re: st: RE: -generate- and run time contingencies


From   Richard Williams <[email protected]>
To   [email protected], <[email protected]>
Subject   Re: st: RE: -generate- and run time contingencies
Date   Mon, 30 Jan 2006 11:16:17 -0500

At 11:07 AM 1/30/2006, Steichen, Thomas J. wrote:
. gen x = uniform()
. replace x = uniform() if x < 0.8

accomplishes what you want.

The above says replace x only if the currrent (run time) value of x is less than 0.8.

Tom
That was my first thought too - but it doesn't work. The problem is that the replacement value may also be less than 0.8. So, you need to be able to repeat the process until all x values are greater than .8.

I believe Mike's second approach would work, but only for data sets that are smaller than 11,000 cases (Stata SE's limit for a matrix - other versions of Stata have even smaller limits.)

Mike's solution of

gen x = 0.8 + 0.2*uniform()

seems to be the best for this example, but perhaps it won't always be so easy. (But then again, maybe it will?)

It is an interesting question - could Mata maybe handle it with large data sets?



-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc
*
* 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