As said, the recipe is
. gen lognormal = exp(<mean> + <sd> * invnorm(uniform()))
So you need to loop over that generating
a set of variables. Say
forval i = 1/100 {
local mean = <plug in>
local sd = <plug>
gen lognormal`i' = exp(`mean' + `sd' * invnorm()))
}
You refer to a uniform distribution. The precise definitions
to be plugged in above would depend on whether that was
defined on the income or log income scale.
I don't think you can _guarantee_ a value < 300,000.
Nick
[email protected]
Jose Marin
> I apologize for the inconvenience.
>
> what I am trying to do is generate random distributions that look like
> income distributions at different periods of time. In that case the
> distributions have to be lognormal and have a lower bound since
> negative income is not feasible, likewise a positive infinity income
> is not feasible ether and the distributions have to be different among
> themselves. So I want the distributions to be generated randomly where
> the numbers in the distribution have a lower limit of zero and an
> upper limit of 300,000 and that they have different means and standard
> deviations that come from a uniform distribution since the
> distributions should have the same chance of being generated.
>
> This is the problem in its fullest expression.
>
> Thank you again. Jose
>
> On 4/30/05, Nick Cox <[email protected]> wrote:
> > It makes sense but it is not precise,
> > as you don't say what distribution(s) the
> > mean and standard deviation come from.
> >
> > I could make guesses at what you mean,
> > but it would be better if you would just
> > state the problem precisely and in one go.
Jose Marin
> >
> > > Thanks Nick,
> > > Now what i meant about mean and sd whithin a range is
> that I need the
> > > distributions to be generated randomly. That is, that the mean and
> > > standard deviations be randomly chosen from a range. The
> end result is
> > > a set of random numbered distribution with randomly
> chosen mean and
> > > standard deviation.
> > >
> > > Does this make any sense??
> >
> > Nick Cox
> >
> > > > A random sample from a lognormal can be generated directly by
> > > >
> > > > . gen lognormal = exp(<mean> + <sd> * invnorm(uniform()))
> > > >
> > > > Here replace <mean> and <sd> by variables or constants giving
> > > > the desired mean(s) and sd(s) of the logged variable.
> > > >
> > > > I am not clear exactly what you mean by "within a ra[n]ge",
> > > > but some variation on this will get what you want.
> > > >
> > > > (Naturally, this is the recipe used by -rndlogn-. In
> > > > the help file for that program, and in the code,
> > > > whenever it says variance, it means sd.)
> >
> > Jose Marin
> >
> > > > > I have a quick question.
> > > > > I am trying to generate a large number of random lognormal
> > > > > distributions with mean and standard deviation within a
> > > rage. I tried
> > > > > using mkbilogn and rndlgn but they generate distributions
> > > around the
> > > > > same inputted mean and standard deviation. I am a new
> Stata user.
*
* 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/