[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Antoine Terracol <terracol@univ-paris1.fr> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Generate a random variable with a range constraint |

Date |
Sat, 06 Dec 2008 20:15:42 +0100 |

Of course, it's g wt= ... and not g /// wt= ... Antoine Antoine Terracol wrote:

Hello David, I'm not sure this is what you want, but the following code clear set obs 5000 scalar sig=70 scalar mu=0.15 scalar up=95 scalar low=45g ///wt=sig*invnorm((normal((up-mu)/sig)-normal((low-mu)/sig))*runiform()+normal((low-mu)/sig))+musu wtgenerates a random variable tuncated at 'low' and 'up', and whose*untruncated* distribution is normal with mean 'mu' and standarddeviation 'sig'hope this helps, Antoine David Collins wrote:I apologise for what may be a fairly rudimentary question. I want togenerate a random variable (wt), n = 5000; as follows;set obs 5000 set seed 1000 g wt = 70 * rnormal(1, 0.15)However, wt also needs to be constrained as follows, 45 < wt < 95. Iam having difficulty incorporating the constraint into the generatefunction, and would appreciate any help.--David* * 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/

* * 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/

**References**:**st: Generate a random variable with a range constraint***From:*David Collins <dcoll@ms.umanitoba.ca>

**Re: st: Generate a random variable with a range constraint***From:*Antoine Terracol <terracol@univ-paris1.fr>

- Prev by Date:
**Re: st: Generate a random variable with a range constraint** - Next by Date:
**Re: st: Re: easy way to put frequencies distribution output in a table** - Previous by thread:
**Re: st: Generate a random variable with a range constraint** - Index(es):

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