Announcement

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

  • Confidence interval for predicted probability after mlogit

    I am using Stata 14.2 to run a multinomal logit (mlogit). After running the model I am using margins to get the predicted probabilities for certain values of my independent variables.
    An issue that is cropping up is that the lower bound of the confidence interval of the predicted probabilities is negative, and apparently not bound to be between 0 or above.

    As an example of what is happening this shows something similar (nonsense example)


    sysuse auto, clear
    mlogit rep78 price i.foreign
    margins foreign, predict(outcome(5))

    Running this we see that the confidence interval of the predicted probabiliy for Domestic and outcome 5 is -0.015 to 0.098

    Is there any way to "correct" the confidence interval?

    Thank you
    Anna Reimondos

  • #2
    You can truncate it at zero.

    You can obtain the linear prediction and then transform it:

    .ÿversionÿ15.1

    .ÿ
    .ÿquietlyÿsysuseÿauto,ÿclear

    .ÿ
    .ÿquietlyÿmlogitÿrep78ÿpriceÿi.foreign

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿmarginsÿforeign,ÿpredict(xbÿoutcome(5))

    PredictiveÿmarginsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿÿ69
    ModelÿVCEÿÿÿÿ:ÿOIM

    Expressionÿÿÿ:ÿLinearÿprediction,ÿrep78==5,ÿpredict(xbÿoutcome(5))

    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿMarginÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿforeignÿ|
    ÿÿÿDomesticÿÿ|ÿÿ-2.608217ÿÿÿ.7361459ÿÿÿÿ-3.54ÿÿÿ0.000ÿÿÿÿ-4.051036ÿÿÿ-1.165397
    ÿÿÿÿForeignÿÿ|ÿÿÿ1.097062ÿÿÿ.6679246ÿÿÿÿÿ1.64ÿÿÿ0.100ÿÿÿÿ-.2120458ÿÿÿÿ2.406171
    ------------------------------------------------------------------------------

    .ÿ
    .ÿtempnameÿT

    .ÿmatrixÿdefineÿ`T'ÿ=ÿr(table)

    .ÿ
    .ÿdisplayÿinÿsmclÿasÿtextÿinvlogit(`T'[5,ÿ1])
    .01710661

    .ÿ
    .ÿexit

    endÿofÿdo-file


    .


    Except in one-off situations, I'd automate this in an ado-file that returns the confidence bounds.

    Comment


    • #3
      Well, some people just truncate the lower limit of the confidence interval at 0. Kludgy, but perfectly consistent with the sampling distribution. -margins- uses the delta method, which does not really deal with this issue.

      Another approach is to run -margins- again and instead of using predict, use -expression(logit(predict(outcome(5))))-. That will get you the predictions of xb. Then you can apply -logit()- to the lower and upper bounds of the confidence limit (which you can pull from the matrix r(table) immediately after -margins-) to get a confidence interval that will respect the 0 and 1 boundaries. Since logit is a monotone function, the confidence limits transform properly in this way.

      Added: Crossed with Joseph Coveney's #2, which proposes the same solution as my second paragraph, but provides code and does it more elegantly.

      Comment


      • #4
        Thank you Joseph and Clyde for the fast and helpful replies. I will have a go at the proposed solution.

        Much appreciated
        Anna

        Comment

        Working...
        X