Bookmark and Share

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: Random draw from log normal distribution with known mean and sd


From   Lulu Zeng <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Random draw from log normal distribution with known mean and sd
Date   Wed, 29 Jan 2014 22:18:13 +1100

Dear Statalist,

This is a subsequent question from my earlier question.

I was trying to work out Willingness to Pay (wtp) from the
coefficients of a random utility model. I tried to use the simulation
method, which takes draws from 2 coefficients' distribution and divide
one by another.

As one of the coefficients is associated with a log normally
distributed price variable, I had to draw firstly from a normal
distribution and -exp it to obtain the log mean and sd. However, my
model outputs are in lognormal, so I had to convert the log normally
distributed mean and sd to normal before using Stata codes to take the
draws.

I got help from Alfonso and Roger and managed to obtain the correct
draws of the log normal (confirm the mean and sd from my draws equals
my original coefficients from the model after all these log to normal
conversions).

However, my wtp calculated is in the wrong range so I suspect I may
have made some mistakes. All I did was drawing from the 2
distributions (1 log the other one normal), put the in 2 columns, and
work out the ratio (attribute divide price). I am not sure if I need
to take random numbers from each distribution and do the division? If
so, it would be really appreciated if you could advise on the Stata
code to achieve this?

Also, regarding converting log normal to normal, I used the wiki
linked from Alfonso and it worked (above cross check). But I read
about other way of doing it but gives totally different results. For
example, equation 6 on page 3 of (this looks to me more like the
formula for converting normal to log normal, which is the other way
round....): http://www.econstor.eu/bitstream/10419/76151/1/613583167.pdf

In addition, a paper by Kennth Train below shows converting log normal
to normal (table 1.1 & table 1.2 on page 8 and 9 respectively) using
this method I was questioning about above too. I replicate the figures
in table 1.2 using the method based on data from table 1.1.
http://elsa.berkeley.edu/~train/trainweeks.pdf

It would be really appreciated if I could have your help on this.


Best Regards,
Lulu








On Tue, Jan 28, 2014 at 9:04 PM, Lulu Zeng <[email protected]> wrote:
> Dear Alfonso and Roger,
>
> Thank you so much for your help. You are right that I incorrectly
> calculated the normal mean and sd from the log form. It is now fixed
> using the formula you suggested.
>
> Thank you again and have a great rest of the day!
>
>
> Best Regards,
> Lulu
>
>
> On Tue, Jan 28, 2014 at 12:00 AM, Roger B. Newson
> <[email protected]> wrote:
>> Another useful source on the lognormal distributon (I find) is Stas
>> Kolenikov's page at
>>
>> http://www.komkon.org/~tacik/science/lognorm.pdf
>>
>> which presents the useful formulas in one place.
>>
>> Best wishes
>>
>> Roger
>>
>> Roger B Newson BSc MSc DPhil
>> Lecturer in Medical Statistics
>> Respiratory Epidemiology, Occupational Medicine
>> and Public Health Group
>> National Heart and Lung Institute
>> Imperial College London
>> Royal Brompton Campus
>> Room 33, Emmanuel Kaye Building
>> 1B Manresa Road
>> London SW3 6LR
>> UNITED KINGDOM
>> Tel: +44 (0)20 7352 8121 ext 3381
>> Fax: +44 (0)20 7351 8322
>> Email: [email protected]
>> Web page: http://www.imperial.ac.uk/nhli/r.newson/
>> Departmental Web page:
>> http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/
>>
>> Opinions expressed are those of the author, not of the institution.
>>
>>
>> On 27/01/2014 12:51, Alfonso Sánchez-Peñalver wrote:
>>>
>>> Hi Lulu,
>>>
>>> please explain how you get the equivalent normal mean and sd of -1.04 and
>>> 0.89 from the lognormal mean and sd of -0.22 and 0.74? Because I think that
>>> is where the problem is. Check
>>> http://en.wikipedia.org/wiki/Log-normal_distribution to see the relationship
>>> with the means and the standard deviations. The following seems close enough
>>>
>>> clear
>>> set obs 5000
>>> generate n = rnormal(-2.77, 1.58)
>>> generate ln = -exp(n)
>>> summarize
>>>
>>> Best,
>>>
>>> Alfonso
>>>
>>> On Jan 27, 2014, at 4:15 AM, Lulu Zeng <[email protected]> wrote:
>>>
>>>> Dear Statalist,
>>>>
>>>> I am seeking your help on take random draws from a log normal
>>>> distribution (with known mean and sd). I am aware similar question has
>>>> been answered on below page but I didn't manage to solve my issue with
>>>> this (http://www.stata.com/statalist/archive/2005-04/msg00999.html).
>>>>
>>>> I am trying to calculate Willingness to Pay (wtp) for a number of
>>>> attributes (variables) of a random utility model (mixed logit in my
>>>> case).
>>>>
>>>> wtp for a particular attribute is defined as the ratio of the
>>>> coefficient for the attribute (e.g., engine performance) to the
>>>> coefficient for the price variable. However, both of the engine
>>>> performance and price coefficients are random in my model -
>>>> performance is normally distributed & price is lognormal distributed.
>>>>
>>>> Given the difference in distribution for the two coefficients, I had
>>>> to use simulation to work out the wtp. That means - take random draws
>>>> from both distribution and divide one by another to work out a
>>>> distribution for wtp.
>>>>
>>>> To achieve this, my first step was to take random draws from my log
>>>> normally distributed price coefficient, which has a log mean & log sd
>>>> of -0.22 and 0.74 respectively (equivalent to a normal mean & sd of
>>>> -1.04 and 0.89 respectively). These figures are the results from my
>>>> model (distribution of the coefficient).
>>>>
>>>> I used below code to take the draw as suggested by the webpage above
>>>> (1200 draws):
>>>>
>>>> gen lognormal = exp(-1.04 + 0.89 * invnorm(uniform()))
>>>>
>>>> To check, I summed the resulting draws from the above, and the draws a
>>>> mean of 0.53 & sd of 0.56. These figures are the same as the -0.22 and
>>>> 0.74 I have above in log form, so I thought there must be something
>>>> wrong.
>>>>
>>>> It would be really appreciated if I could have your help on this.
>>>>
>>>>
>>>> Best Regards,
>>>> Lulu
>>>> *
>>>> *   For searches and help try:
>>>> *   http://www.stata.com/help.cgi?search
>>>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>>>> *   http://www.ats.ucla.edu/stat/stata/
>>>
>>>
>>>
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>>> *   http://www.ats.ucla.edu/stat/stata/
>>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index