Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: The function " invnorm(uniform())"


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: st: The function " invnorm(uniform())"
Date   Thu, 24 Apr 2003 12:46:40 +0100

[email protected] wrote:

I am using the function "invnorm(uniform())" which returns normally
distributed random numbers with mean zero and standard deviation one,
inside a program "linsim.ado". The latter is used with:

simul linsim, reps(10000)

program define lnsim
version 7.0
if "`1'"=="?" {
global S_1 "eff diag1 diag2"
exit
}
drop _all
set obs 1
gen eff = uniform()*100
gen diag1 = invnorm(uniform())
gen diag2 = invnorm(uniform())*1.5 + 5
post `1' (eff) (diag1) (diag2) end

Can I say that the variable "diag2", is a normally distributed random number
with mean 5 and standard deviation 1.5.
Yes, but you need not use -simul- to get this. Just do it directly:

set obs 10000
gen eff = uniform()*100
gen diag1 = invnorm(uniform())
gen diag2 = invnorm(uniform())*1.5 + 5
outfile eff diag1 diag2

Nick
[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/



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