Statalist The Stata Listserver


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

st: Re: Generating independent standard normal variables


From   Joseph Coveney <[email protected]>
To   Statalist <[email protected]>
Subject   st: Re: Generating independent standard normal variables
Date   Mon, 02 Apr 2007 13:33:17 +0900

Tiago Pereira wrote:

I have to compute the statistical power of a test. To do that, I need to
generate several independent standard normal variables.

Let Zi; 1 =< i =< k denote independent standard normal variables, and k a
value ranging from 1 to 200. How do I generate 1000 independent standard
normal variables using Stata supposing that k=18?

--------------------------------------------------------------------------------

Consider using -generate-.  The expectation for rho is zero, which might be
better for your purpose, if it's to do power analysis by simulation.  If you
need to specify orthogonal correlation structure for a given set of
variables, then you would use -drawnorm-.

Joseph Coveney

clear
set more off
set seed 12345
set obs 1000
local k 18 // You can change this from 1 to 200.
forvalues i = 1/`k' {
   generate double Z`i' = invnormal(uniform())
}
exit

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