Announcement

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

  • Predicted probabilities after mi estimate: mlogit

    Hello!

    I am estimating multinomial logistic regression using mi estimate: mlogit. I need to get predicted probabilities for all outcome categories.
    For example, if I use regular dataset without multiple imputations I would do this (I used simulated data):

    Code:
    clear all
    set obs 1000
    
    g x1 = invnorm(runiform())
    g x2 = invnorm(runiform())
    g x3 = invnorm(runiform())
    
    gen byte y=1
    forval i=1/3 {
        replace y=y+1 if runiform()<.3+.1*x1+.2*x2-.3*(!x3)
    }
    
    tab y
    
    foreach var of varlist x1-x3 {
        replace `var' = . if runiform()<.2
        }
    
    mlogit y x1 x2 x3
    
    predict pr1 pr2 pr3 pr4, pr
    This will give me predicted probabilities for each of the outcome categories. However, I cannot do the same with mi data.
    My code is:

    Code:
    mi set flong
    mi reg imp x1 x2 x3
    
    mi impute chained (pmm, knn(10)) x1 x2 x3 = y, add(10)
    
    mi estimate, saving(simulation.ster, replace): mlogit y x1 x2 x3
    
    mi predict nxb1 using simulation.ster, storecompleted equation(#1)
    mi predict nxb2 using simulation.ster, storecompleted equation(#2)
    mi predict nxb3 using simulation.ster, storecompleted equation(#3)
    mi predict nxb4 using simulation.ster, storecompleted equation(#4)
    
    sum nxb*
    mi xeq: generate nps1 = invlogit(nxb1)
    mi xeq: generate nps2 = invlogit(nxb2)
    mi xeq: generate nps3 = invlogit(nxb3)
    mi xeq: generate nps4 = invlogit(nxb4)
    
    
    sum nps*
    This gives me a constant probability for category 4 (0.5), which is because the linear prediction for this category is 0 (since it is base outcome). Is there any way to do something similar that predict command after mlogit do in the regular settings?

    Thank you in advance!
    Last edited by Katya Baldina; 01 Oct 2023, 12:56.

  • #2
    Code:
    h mi predict

    Comment


    • #3
      Originally posted by Rich Goldstein View Post
      Code:
      h mi predict
      Thank you for your reply! I've already went through all help file for "mi predict" that's why I came here If you know the solution, could you please share it with me?

      Comment


      • #4
        Originally posted by Katya Baldina View Post

        Code:
        (code omitted)
        mi xeq: generate nps1 = invlogit(nxb1)
        mi xeq: generate nps2 = invlogit(nxb2)
        mi xeq: generate nps3 = invlogit(nxb3)
        mi xeq: generate nps4 = invlogit(nxb4)

        I don't think this code is correct. The predicted probababilty for category \(i\) in a multinomial logit is given by

        \[
        \frac{exp(xb_i)}{1+\sum_j{exp(xb_j)}}
        \]

        where \(i \neq j\).

        Thus, the code should be along the lines:

        Code:
        mi xeq: generate nps1 = exp(nxb1) / ( exp(nxb2) + exp(nxb3) + exp(nxb4) )

        Comment


        • #5
          Originally posted by daniel klein View Post
          Code:
          mi xeq: generate nps1 = exp(nxb1) / ( exp(nxb2) + exp(nxb3) + exp(nxb4) )
          should be

          Code:
          mi xeq: generate nps1 = exp(nxb1) / ( 1 + (exp(nxb2) + exp(nxb3) + exp(nxb4)) )

          Comment

          Working...
          X