Announcement

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

  • Predict after Firthlogit

    To calculate the Human Opportunity Index I need the probabilities that are obtained by using the command "predict prob" after logistic regression. It occurs, however, I detected in my database a quasi-complete separation problem in logistic regression, so I can not use logistic regression. To solve the problem of quasi-complete separation I am using the command "firthlogit", however, I would like to know how to get the probabilities, because the command "predict prob" returns me something that can not be the probabilities, since the values are not in decimal scale, and moreover some of them are negative.

    Please, help me.

  • #2
    predict after the user-written program firthlogit (SSC) creates the linear prediction. Use the invlogit() function to convert it.
    Code:
    sysuse auto, clear
    
    firthlogit foreign i.rep78, nolog
    predict double xb
    generate double pr_pl = invlogit(xb) // <= here
    
    logit foreign i.rep78, nolog
    predict pr_ml, pr
    
    tabulate pr_*

    Comment


    • #3
      Thanks, Joseph.

      To see if I correctly followed your instructions, I wonder if the pr_pl and pr_ml must be the same as in the case with which I am working it did not. For none of the comments the values were equal and the differences of extremes reached almost 4%. There are situations, for example, in two equal pr_ml values corresponding to different values of pr_pl.

      Comment


      • #4
        I see two issues here. One is that you specified type double in the first -predict- command, but not in the second. That pretty much ensures that the results can contain some discrepancies.

        But more important, -firthlogit- and -logit- are different models, and they should produce somewhat different results. (For samples containing complete separation or near complete separation, the differences could in fact be pretty large.) So there is no reason to expect the predicted probabilities to match more than just approximately.

        Comment


        • #5
          Clyde,

          Focusing only on the first issue for you highlighted I would like to know what to do as the first command predict and the sequence of the code so that I can perhaps closer to the results obtained with firthlogit and logit.

          Comment


          • #6
            Originally posted by Girlan Oliveira View Post
            . . . I wonder if the pr_pl and pr_ml must be the same as in the case with which I am working it did not. For none of the comments the values were equal and the differences of extremes reached almost 4%. There are situations, for example, in two equal pr_ml values corresponding to different values of pr_pl.
            The predictions would not be expected to be equal. The cross-tabulation was in order to illustrate that although the predictions are usually (but not always) in the same range, they are not equal. This is despite the programming error (failing to make the maximum likelihood predictions as double-precision) that Clyde rightly points out.

            The cross-tabulation also shows the same situation that you mention: observations that have equal values of the maximum likelihood prediction (0.82) but have two different values (0.17 and 0.79) of the penalized maximum likelihood prediction.

            Comment


            • #7
              Originally posted by Girlan Oliveira View Post
              . . . I would like to know what to do as the first command predict and the sequence of the code . . .
              Something like this:
              Code:
              predict double pr, xb
              quietly replace pr = invlogit(pr)

              Comment

              Working...
              X