Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: rndlgn 500 1 -1
From
"Nick Cox" <[email protected]>
To
<[email protected]>
Subject
RE: st: rndlgn 500 1 -1
Date
Sun, 11 Apr 2010 18:03:19 +0100
A fuller answer requires attention to the code, as a standard deviation of -1 makes no more sense than a variance of -1. The -exp()- call shows that the standard deviation is measured on natural logarithmic scale, so -1 means exp(-1), which is certainly positive.
Nick
[email protected]
Tirthankar Chakravarty
Here is the -trace- from your command:
******************************************************
- version 3.1
- cap drop xlgn
- qui {
- local cases `1'
= local cases 500
- set obs `cases'
= set obs 500
- mac shift
- local mn `1'
= local mn 1
- mac shift
- local var `1'
= local var -1
- mac shift
- tempvar ran1
- noi di in gr "( Generating " _c
( Generating - gen `ran1' = exp(`mn'+`var' * invnorm(uniform()))
= gen __000000 = exp(1+-1 * invnorm(uniform()))
- gen xlgn = `ran1'
= gen xlgn = __000000
- noi di in gr "." _c
.- noi di in gr " )"
)
- noi di in bl "Variable " in ye "xlgn " in bl "created."
Variable xlgn created.
- }
******************************************************
As you can see in the line
= gen __000000 = exp(1+-1 * invnorm(uniform()))
the "variance" input is used as standard deviation instead.
By the way, -rnd- (STB) is due to Joseph Hilbe and Walter Linde-Zwirble.
2010/4/10 sun samn <[email protected]>:
> I cannot believe that 'rndlgn 500 1 -1' this works in stata!
> you know, the variance of '-1' should not make any sense! Does someone know what it is really going on there?
*
* 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/