Statalist


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

st: AW: random deviates from a distribution with truncation


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: random deviates from a distribution with truncation
Date   Tue, 7 Jul 2009 22:49:01 +0200

<> 

Look at "mus04p1sim.do" in http://www.stata-press.com/data/mus/mus.zip, line
189-198:


*************
* Draws from truncated normal x ~ N(mu,sigma^2) in [a,b]
quietly set obs 2000
set seed 10101
scalar a = 0                             // lower truncation point
scalar b = 12                            // upper truncation point
scalar mu = 5                            // mean
scalar sigma = 4                         // standard deviation
generate u = runiform()
generate
w=normal((a-mu)/sigma)+u*(normal((b-mu)/sigma)-normal((a-mu)/sigma))
generate xtrunc = mu + sigma*invnorm(w)
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von fleur wouterse
Gesendet: Dienstag, 7. Juli 2009 17:55
An: statalist@hsphsun2.harvard.edu
Betreff: st: random deviates from a distribution with truncation

Dear all, 

Although, I have found programmes for generated random deviates (gennorm) as
well as a random sample from a truncated distribution (gentrun), I am not
able to find a program that generates random deviates from a truncated
distribution. Does such a program exist?

Your help is appreciated, 

Fleur Wouterse







      

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



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