Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
jhilbe@aol.com |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: RE: generate lognormal RV less than 20000 observations. |

Date |
Tue, 13 Apr 2010 14:22:26 -0400 |

pseudo-random numbers are generated - whatever is allowed by your memory

of 0 and a SD of .5. Am I missing something? . rndlgn 10 0 .5 ( Generating . ) Variable xlgn created. . list +-----------+ | xlgn | |-----------| 1. | 1.3562985 | 2. | .46046644 | 3. | .37838322 | 4. | .94114434 | 5. | 1.6200692 | |-----------| 6. | 1.1143121 | 7. | .52069493 | 8. | 1.4824923 | 9. | 2.7165885 | 10. | .35047758 | +-----------+

Joseph Hilbe Date: Sun, 11 Apr 2010 17:53:10 +0100 From: "Nick Cox" <n.j.cox@durham.ac.uk> Subject: RE: st: RE: generate lognormal RV less than 20000 observations. Sun Samn made two points. First, "Sorry, I just updated my rndlgn; the old one does require 20000 or more." There is some misunderstanding by Sun here. For a long time, the -rnd- package by Joseph Hilbe and W. Linde-Zwirble was the most developed way to get random deviates in Stata. -rnd- includes -rndlgn-. Typing . findit rndlgn reveals the facts. Search of official help files, FAQs, Examples, SJs, and STBs STB-41 sg44.1 . . . . . . . . . . . . Correction to random number generators

1/98 p.23; STB Reprints Vol 7, p.166 faster version plus minor changes STB-28 sg44 . . . . . . . . . . . . . . . . . . . . Random number generators (help rnd if installed) . . . . . . . . J. Hilbe and W. Linde-Zwirble 11/95 pp.20--21; STB Reprints Vol 5, pp.118--121 programs to implement random number generators that allows user to generate synthetic data from a variety of distributions Web resources from Stata and other users (contacting http://www.stata.com) sg44_1 from http://www.stata.com/stb/stb41 STB-41 sg44_1. Correction to random number generators. / STB insert by /

sg44 from http://www.stata.com/stb/stb28

Walter Linde-Zwirble. / Support: atjmh@asuvm.inre.asu.edu / After installation, see help rnd. rnd from http://www.stata.com/users/jhilbe

programs generate random numbers for a variety of important /

rnd from http://fmwww.bc.edu/RePEc/bocode/r

STB-44. They allow for / noncentrally distributed random numbers,

As I said, there has never been any such requirement of -rndlgn- to have 20000 or more observations. I don't know where such a bizarre idea comes from. The help gives various examples of using -set obs- before you call the -rnd- commands. Independently of that, the -rnd- programs will increase the dataset size if the number of observations specified is greater than the number of observations in memory. But the treatment of dataset size has not changed at all in the public lifetime of -rndlgn-,

The most notable change between STB-28 and SSC versions is a correction

. type http://www.stata.com/stb/stb28/sg44/rndlgn.ado

* Example: rndlgn 1000 0 .5 [set obs 1000; 0 = mean; .5 = variance] program define rndlgn version 3.1 cap drop xlgn qui { local cases `1' set obs `cases' mac shift local mn `1' mac shift local var `1' mac shift tempvar ran1 noi di in gr "( Generating " _c gen `ran1' = exp(`mn'+`var' * invnorm(uniform())) gen xlgn = `ran1' noi di in gr "." _c noi di in gr " )" noi di in bl "Variable " in ye "xlgn " in bl "created." } end . ssc type rndlgn.ado *!version 1.1 1999 Joseph Hilbe

program define rndlgn version 4.0 set type double cap drop xlgn qui { local cases `1' set obs `cases' mac shift local mn `1' mac shift local var `1' mac shift tempvar ran1 noi di in gr "( Generating " _c gen `ran1' = exp(`mn'+`var' * invnorm(uniform())) gen xlgn = `ran1' noi di in gr "." _c noi di in gr " )" noi di in bl "Variable " in ye "xlgn " in bl "created." lab var xlgn "Lognormal random variable" set type float } end Second, " For my case, I prefer to use rndlgn instead of exp(normal) because I wanna [meaning:want to] specify heteroskedasticity." There is no real difference here. In Stata 10.1 up, you can call -rnormal()- with specified mean and standard deviation; either or both could be given via variable names, or indeed more complicated expressions. This is quite as flexible as, indeed slightly more flexible than, using -rndlgn-, as the latter reliably supports only single numbers or variable names as arguments. Nick n.j.cox@durham.ac.uk sun samn Sorry, I just updated my rndlgn; the old one does require 20000 or more. For my case, I prefer to use rndlgn instead of exp(normal) because I wanna specify heteroskedasticity. n.j.cox@durham.ac.uk

This sparked a thread with Martin Weiss. I have four comments by way

of summarizing and going beyond that exchange.

1. Please do specify where user-written software you refer to comes

from.

(Most postings from Sun Samn ignore advice in the FAQ in at least one

way.)

2. It is quite untrue that -rndlgn- requires 20,000 observations. 3. In this case, the user-specified software is not, and never has

been, needed. A one-line call with reference to -exp(rnormal())- gets you random draws from a lognormal quite directly. (Before -rnormal()- was introduced, other functions could be used, and indeed were used internally within -rndlgn-. I imagine that for their own reasons Joe Hilbe and friend wanted something uniform in syntax with the other commands that they wrote a while back.)

4. -rndlgn- is a command, not a function. -exp()- and -rnormal()- are

functions. sun samn

I know the function ' rndlgn' can generate lognormal RVs, but it

requires the numbers of observation to be at 20000. Now, I want a list of only 500. What should I do then? * * * 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/

- Prev by Date:
**Re: st: Comparing proportions using survey data** - Next by Date:
**st: Fwd: Heckman model Vs treatment regression model** - Previous by thread:
**st: Capturing and Sharing Screen Images** - Next by thread:
**st: Fwd: Heckman model Vs treatment regression model** - Index(es):