Sorry - my correction statement was not all there.It should have read "I
inadvertently left out the exponential function "exp" operating on the
expression for E(Y^2)". Corrected version is below.
E(Y^2) = E( (exp(x))^2 ) = E(exp(2X)) = exp(2*mu + 4*sig2/2) = exp(2*mu
+ 2*sig2).
al F.
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Feiveson,
Alan H. (JSC-SK311)
Sent: Tuesday, September 12, 2006 9:00 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: simulating a lognormal distribution (correction)
for E(Y^2). Corrected version is below.
al F.
Jeph - Let X = log(Y). You can use the fact that E(exp(tX)) = exp(mu*t +
t*t*sig2/2) where X~N(mu,sig2). Taking t=1,we see that E(Y) = mu +
sig2/2. Also the median of Y is exp(median of X) = exp(mu). So from the
mean and median of Y, you can get values for mu and sig. The sd of Y
adds additional information if you want to use it. Taking t=2, gives
E(Y^2) = E( (exp(x))^2 ) = E(exp(2X)) = exp(2*mu + 4*sig2/2) = exp(2*mu
+ 2*sig2). From this you can get Var(Y)=E(Y^2) - (E(y))^2 also as some
function of mu and sig2. Then you have three equations and two unknowns
(mu and sig)and you could solve for mu and sig by some sort of weighted
least squares. But I think the sample variance (or sd) of a lognormal RV
is not very reliable statistic and I would go with just the mean and
median to estimate mu and sig.
Al Feiveson
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Jeph Herrin
Sent: Tuesday, September 12, 2006 8:24 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: simulating a lognormal distribution
This is not, strictly speaking, a Stata problem, but I am hoping to find
a Stata solution.
I am trying to simulate a lognormal distribution, but have only the
median (which I'm willing to assume is the log mean) plus the mean and
sd of the non-log transformed data. Put another way, I have median, mean
and sd of Y, but log(Y) is normal, and I would like to simulate Y.
I have found -rndlgn-, which will simulate a random log normal
distribution, but only if I have the mean and sd of log(Y). The only
idea I have is to generate a series of log normal distributions X with
mean = log(median(Y)) and a range of sds, until I end up with one where
exp(X) has the mean and sd of Y. But this seems overly computing
intensive for my purposes, as I will need to do this for a large number
of obs with a loop that runs many times.
Any other ideas? In particuar, am I missing an obvious way to get the
mean & sd of log(Y) from the mean and sd of Y?
thanks,
Jeph
*
* 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/
*
* 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/
*
* 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/