Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lognormal distribution

    Hi, i need to generate an "x" amount of number that follow a lognornal distribution with a certain mean and standard deviation for simulate income, but i don't know how i can do, I have already search in a lot of forum but i don't find anything. Someone can help me? Thanks.

    Enrico

  • #2
    A lognormal is just a normal exponentitated. So use exp(rnormal())

    Comment


    • #3
      I'm using stata 8, and it don't recognise that command. possible? I'm using stata only a few weeks, maybe i'am doing something wrong.

      Comment


      • #4
        It's a nested function call, not a command.

        Please note as part of the FAQ Advice you were asked to read before posting. http://www.statalist.org/forums/help#version

        11. What should I say about the version of Stata I use?



        The current version of Stata is 14.2. Please specify if you are using an earlier version; otherwise, the answer to your question may refer to commands or features unavailable to you. Moreover, as bug fixes and new features are issued frequently by StataCorp, make sure that you update your Stata before posting a query, as your problem may already have been solved.
        It's a while since I used Stata 8, but equivalent syntax might be

        Code:
        exp(invnorm(uniform()))
        See help functions in your Stata.

        Comment


        • #5
          ok thanks, it run. i will see help function to set it uo right.

          Comment


          • #6
            Originally posted by Nick Cox View Post
            A lognormal is just a normal exponentitated. So use exp(rnormal())
            Hi Nick,

            If I use the command "exp(rnormal(mean,sd))", I can only generate the lognormal distribution in which the mean and sd are based on its corresponding normal distribution. Is this the common way of specifying a lognormal distribution (or more specifically, in the literature of income inequality, if you happen to be familiar with it by any chance)? This looks a bit strange to me.

            If not, to your knowledge is there any easy way to generate a random lognormal distribution by specifying its own mean and sd instead of the mean and sd of its corresponding normal distribution? I could firstly transform the parameters of my desired lognormal distribution into the parameters of its corresponding normal distribution according to https://ocw.mit.edu/courses/civil-an...nts8_relnl.pdf, but this just seems very cumbersome to me and I suspect there should be an easier approach in Stata.

            Thank you!

            Comment


            • #7
              Shem:
              you can find details on what you're after at -help simulate-.
              Kind regards,
              Carlo
              (StataNow 18.5)

              Comment


              • #8
                shem shen I wrote about this some years ago, but I can't find the post. The link you give shows the result of the necessary algebra. All you need in Stata is one messy statement, so that is one reason why a dedicated command or egen function is not obvious.

                https://stat.ethz.ch/~stahel/lognormal/ is an interesting site with several links. I think there should be a society for people who find power laws oversold, and the lognormal often not too bad as a first approximation, but it would need a catchy name.

                Comment


                • #9
                  Nick Cox Thank you very much for the website! It indeed recommends using the back-transformed mean and sd of the normal distribution to characterize the lognormal distribution.
                  Carlo Lazzaro Thank you! I am not aware of this command before.

                  Comment

                  Working...
                  X