Announcement

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

  • How to do the plot of standardized deviance residual against the predicted value of the index function after fitting logit model in Stata?

    As suggested by the title, I want to fit a logit model and graph the plot of the standardized deviance residual against the predicted value of the index function.
    However, I really don't know how to do this in Stata. Meanwhile, I don't know how to graph the residual-predictor plot in Stata as well.
    Can someone help me?
    Thank you!

    webuse auto,clear
    logit foreign price mpg rep78

  • #2
    Jason:
    see -help regress postestimation plots-.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Jason:
      see -help regress postestimation plots-.
      I used rvpplot command to do it and it doesn't work at all.
      Anyway, Thank you!

      Comment


      • #4
        Jason:
        do you mean something along the following lines?
        Code:
        . use https://www.stata-press.com/data/r17/auto.dta
        (1978 automobile data)
        
        . logit foreign i.rep78 mpg
        
        <snip>
        
        Logistic regression                                     Number of obs =     59
                                                                LR chi2(3)    =  25.87
                                                                Prob > chi2   = 0.0000
        Log likelihood = -25.478287                             Pseudo R2     = 0.3367
        
        ------------------------------------------------------------------------------
             foreign | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
               rep78 |
                  1  |          0  (empty)
                  2  |          0  (empty)
                  3  |  -3.136422   1.044601    -3.00   0.003    -5.183803    -1.08904
                  4  |  -1.119903   .9741478    -1.15   0.250    -3.029198    .7893916
                  5  |          0  (omitted)
                     |
                 mpg |   .1310946    .070733     1.85   0.064    -.0075396    .2697287
               _cons |  -1.723275   1.776453    -0.97   0.332    -5.205059    1.758509
        ------------------------------------------------------------------------------
        
        . predict fitted, xb
        
        
        . predict dev_res, deviance
        
        
        . twoway (scatter dev_res fitted)
        
        .
        Last edited by Carlo Lazzaro; 03 May 2022, 00:19.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          Jason:
          if what above does not work, please share an example/experpt of your dataset via -dataex-. Thanks.
          Last edited by Carlo Lazzaro; 03 May 2022, 00:21.
          Kind regards,
          Carlo
          (StataNow 18.5)

          Comment


          • #6
            I just asked my friend and he told me that the code should be as follows,

            webuse auto,clear
            logit foreign price mpg rep78
            rvpplot2 weight, yli(0)

            Comment


            • #7
              Originally posted by Carlo Lazzaro View Post
              Jason:
              if what above does not work, please share an example/experpt of your dataset via -dataex-. Thanks.
              Thank you!
              But I really don't know if what you just posted is the solution to my question.

              Comment


              • #8
                Originally posted by Carlo Lazzaro View Post
                Jason:
                do you mean something along the following lines?
                Code:
                . use https://www.stata-press.com/data/r17/auto.dta
                (1978 automobile data)
                
                . logit foreign i.rep78 mpg
                
                <snip>
                
                Logistic regression Number of obs = 59
                LR chi2(3) = 25.87
                Prob > chi2 = 0.0000
                Log likelihood = -25.478287 Pseudo R2 = 0.3367
                
                ------------------------------------------------------------------------------
                foreign | Coefficient Std. err. z P>|z| [95% conf. interval]
                -------------+----------------------------------------------------------------
                rep78 |
                1 | 0 (empty)
                2 | 0 (empty)
                3 | -3.136422 1.044601 -3.00 0.003 -5.183803 -1.08904
                4 | -1.119903 .9741478 -1.15 0.250 -3.029198 .7893916
                5 | 0 (omitted)
                |
                mpg | .1310946 .070733 1.85 0.064 -.0075396 .2697287
                _cons | -1.723275 1.776453 -0.97 0.332 -5.205059 1.758509
                ------------------------------------------------------------------------------
                
                . predict fitted, xb
                
                
                . predict dev_res, deviance
                
                
                . twoway (scatter dev_res fitted)
                
                .
                Thank you!
                But I really don't know if what you just posted is the solution to my question.
                predicted value of the index function====predict fitted, xb?

                Comment


                • #9
                  Jason:
                  Code:
                  webuse auto,clear
                  logit foreign price mpg rep78
                  rvpplot2 weight, yli(0)
                  how can it be? -weight- is not included as a predictor in the right-hand side of your regression equation.
                  That said:
                  1) the index function details the relationship between the covariates (right-hand side of your regression equation) and the outcome (left-hand side of your regression equation) (see, if interested,
                  2) if you have a different notion/idea/whatever about 1), please share it with the list ( the risk of an xy problem cannot be ruled out on a priori basis; see, if interested: https://xyproblem.info ;
                  3) as per FAQ, stating that a given command/function/whatever does not work as expected, is not informative.
                  Kind regards,
                  Carlo
                  (StataNow 18.5)

                  Comment


                  • #10
                    Thank you!
                    It is a typo. It should be price rather than weight.

                    Comment

                    Working...
                    X