Announcement

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

  • mlogit - estimate probability for specific value

    Hello stata community

    I run the following command
    Code:
    mlogit y x1 x2 x3 i.year
    Where y takes 3 values 0, 1, 2

    Now I want to estimate the probability for a specific value of X. For example:
    - x1=2, x2=5, x3=7, year=2000
    - Estimate probability for y = 1

    Then save the predicted probability to a scalar variable. I read the manual, there is a predict but don't know how to add the specific value for probability estimation

    Thank you

  • #2
    Code:
    margins, predict(outcome(1)) at(x1 = 2 x2 = 5 x3 = 7 year = 2000)
    To access the result and save it as a scalar
    Code:
    scalar wanted = r(b)[1,1]

    Comment


    • #3
      margins can do this for you.

      To get the probabilities for each outcome, but without standard errors, try
      Code:
      margins, nose at(x1=2 x2=5 x3=7 year=2000)
      The resulting probabilities are posted to matrix r(b).

      To get the probability for y=1, try
      Code:
      margins, nose at(x1=2 x2=5 x3=7 year=2000) predict(outcome(1))
      Here is a simple example using the auto data
      Code:
      sysuse auto
      mlogit rep78 turn trunk displ
      margins, nose at(turn=40 trunk=15 displacement=195) predict(outcome(1))
      matrix list r(b)

      Here is the output from margins.
      Code:
      . margins, nose at(turn=40 trunk=15 displacement=195) predict(outcome(1))
      
      Adjusted predictions                                        Number of obs = 69
      
      Expression: Pr(rep78==1), predict(outcome(1))
      At: turn         =  40
          trunk        =  15
          displacement = 195
      
      ------------------------------------------------------------------------------
                   |     Margin
      -------------+----------------------------------------------------------------
             _cons |   .0017822
      ------------------------------------------------------------------------------
      
      . matrix list r(b)
      
      symmetric r(b)[1,1]
              _cons
      r1  .00178223

      Comment


      • #4
        Jeff Pitblado (StataCorp)
        Clyde Schechter

        Thank you so much for your help
        The solution works excellent

        Comment


        • #5
          The mtable command from Long and Freese’s spost13 routines is really great for producing nicely formatted output. See the first few pages of

          https://www3.nd.edu/~rwilliam/xsoc73994/Margins05.pdf
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          StataNow Version: 19.5 MP (2 processor)

          EMAIL: [email protected]
          WWW: https://academicweb.nd.edu/~rwilliam/

          Comment

          Working...
          X