Announcement

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

  • mimrgns for adjusted probability in a logistic regression: how to calculate the correct standard errors?

    Hello all, I am working on a multiple imputed dataset and trying to use a logistic regression model to get an adjusted probability of a binary outcome (adherence) for wealth (the model has been adjusted for education and race). I used the command -mimrgns- to get the result and want to pass the results to -marginsplot- to have the plot. However, I had a negative confidence interval (below 0) when I evaluated the confidence interval for the adjusted probability of adherence.

    Here is the code:

    Code:
    mi estimate: logit Adherence_Binary i.edu i.race i.wealth
    
    mimrgns i.sex predict(pr) cmdmargins
    Here is what I got:

    Code:
    Multiple-imputation estimates                      Imputations = 25
    Predictive margins                                       Number of obs = 426
                                                                       Average RVI = 0.0310
                                                                       Largest FMI = 0.0583
    DF adjustment: Large sample                      DF: min = 7,131.68
                                                                        avg = 5.87e+07
    Within VCE type: Delta-method                 max = 1.17e+08
    
    Expression : Pr(Adherence_Binary), predict(pr)
    
    ---------------------------------------------------------------------------------------
    | Margin Std. err. t P>|t| [95% conf. interval]
    ----------------------+----------------------------------------------------------------
    wealth |
         yes | .5148526 .3444198 1.49 0.135 -.1603124 1.190018
           no | .4289501 .0196527 21.83 0.000 .3904315 .4674688
    ---------------------------------------------------------------------------------------
    I searched online to find why I got a negative lower confidence interval and think that it is because (1) I only have very few (around 5) people belonging to yes and (2) the model uses the delta VCE to evaluate the standard errors. The delta method ignores the boundary and calculates the standard error without considering that the adjusted probability should fall in [0,1].

    I am trying to get the correct standard error by applying a different vce, but it does not work - I do not know how to use a different vce in -mimrgns-. And I am also uncertain which vce I should use to evaluate the standard error.

    Can anyone offer me suggestions on which vce method I should use, and whether -mimrgns- accept a different vce to evaluate the standard error?
    If -mimrgns- cannot work, do you have any other advice on any other commands that I can use to obtain the correct standard error and then the correct confidence interval and pass it to -marginsplot-? (I am afraid that I have to use -marginsplot- because I try to combine several graphs and they all use -marginsplot-)

    Any suggestions are greatly appreciated! Thank you for reading the post!

    Best,
    Lu
    Last edited by Patricia Lu; 19 Dec 2023, 22:28.

  • #2
    I don't think the problem here is primarily with the standard error. The problem is more with how the CIs are constructed. This is discussed in an FAQ and has been discussed on the old listserver. The former reference explicitly notes that transforming CIs from the linear predictor is better than constructing CIs from the standard errors, especially if you want CIs to fall within [0,1].

    You could transform the CIs from the linear predictor that you get from mimrgns (as a default). However, that won't help much because marginsplot reconstructs the CIs from the coefficient vector and covariance matrix. I have no idea how to best proceed here.

    Edit: mimrgns is (probably) from SSC. Note that the problem is not specific to mimrgns. It might be better to construct an example using the standard margins command and see whether anyone comes up with a suggestion.
    Last edited by daniel klein; 20 Dec 2023, 04:30.

    Comment


    • #3
      there is an undocumented command _coef_table with undocumented citype(logit) option that will produce the appropriately-bounded CI's after a margins command.
      Code:
      _coef_table, citype(logit) cititle(Logistic)
      however, the marginsplot command does not use the corrected CI.
      this iimitation is noted frequently in this forum and i think a feature enhancement might be possible.

      see https://www.statalist.org/forums/for...06#post1736206
      Last edited by George Hoffman; 20 Dec 2023, 06:20.

      Comment


      • #4
        Thanks Daniel and Geroge for offering the solutions! I checked the FAQ website regarding the prediction of CI for probability in a logistic regression and found it useful. The command -marginsplot-, however, still cannot work.

        I am turning to another command -coefplot- and used -transform_margins- to get the CI (verified by manually following the formula in the FAQ link). The command -transform_margins- allows STATA to produce a matrix with probability with a correct confidence interval calculated from the linear predictor.

        Just want to post the solution so that anyone who has the same question may find it useful! Thanks everyone again for your support and suggestions!

        Comment


        • #5
          transform_margins is from http://www.stata.com/users/jpitblado.
          coefplot might be from SSC; might also be from SJ (or GitHub)

          Would you mind posting the relevant syntax?
          Last edited by daniel klein; 20 Dec 2023, 07:21.

          Comment


          • #6
            Sure, the source of the command -transform_margins- is correct, and the source of coefplot can be found here: http://github.com/benjann/coefplot

            Here is the code:

            Code:
            mi estimate: logit Adherence_Binary i.edu i.race i.wealth
            mimrgns i.wealth, expression(predict(xb)) cmdmargins
            
            transform_margins invlogit(@), matrix(wealth)
            
            coefplot matrix(wealth[,1]), ci((wealth[,2] wealth[,3]))
            If the code helps, that will be great!

            Also, I am trying to use -graph combine- to combine several plots of adjusted proportion, they have the same x axis for adjusted proportion, but as they have label of different lengths, their y axis does not align well.

            I am wondering if anyone has an idea on how I can align the graphs to keep the start point for every plot on the same line?

            Comment


            • #7
              As for graph combine, I would discuss that as a new topic, providing a minimal example.

              Thanks for providing syntax, which is usually more helpful than (only) verbal description.

              Notice that the code in #6 will generally not produce the same coefficients that you would get from

              Code:
              mimrgns ... , predict(pr)
              Nor will it produce the coefficients discussed in [MI] mi predict -- Example 3: Obtain MI estimates of probabilities. I am not saying or even implying that this is necessarily a problem. I just want to point to otherwise easily overlooked differences.

              Comment


              • #8
                Thanks for reminding me of that! Definitely will check!

                Comment

                Working...
                X