Announcement

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

  • RE: Standard deviation of the residual

    I ran logistic regression of y. I saved the residuals after estimating the regression.

    Step 1: logit y x1 x2 x3
    Step 2: predict resid, residuals

    From the second step, I can obtain the standard deviation of the residuals. That is just one number.

    Next, I want to store the standard deviation of the residual for each observation. Would please provide stata codes? Any help would be appreciated.
    Last edited by DY Kim; 17 Sep 2020, 09:11.

  • #2
    To compute the standard deviation of the residual, I used the code below. However, it gave the error message.

    . predict stdr, stdr
    option stdr not allowed
    r(198);


    Comment


    • #3
      not sure what your question is in #2, but to see what options are allowed for -predict- after a -logit-, see
      Code:
      help logit postestimation##predict

      Comment


      • #4
        Step 1: logit y x1 x2 x3
        Step 2: predict resid, residuals
        Step 3: predict stdr, stdr

        I already checked the stata command. To compute the standard deviation of the residuals, I use "predict stdr, stdr." I received the error message: "option stdr not allowed r(198);"

        Comment


        • #5
          DY:
          you may want to consider:
          Code:
          . use "C:\Program Files\Stata16\ado\base\a\auto.dta"
          (1978 Automobile Data)
          
          . logit foreign price mpg, vce(cluster foreign)
          
          Iteration 0:   log pseudolikelihood =  -45.03321  
          Iteration 1:   log pseudolikelihood = -36.627434  
          Iteration 2:   log pseudolikelihood = -36.462562  
          Iteration 3:   log pseudolikelihood =  -36.46219  
          Iteration 4:   log pseudolikelihood = -36.462189  
          
          Logistic regression                             Number of obs     =         74
                                                          Wald chi2(0)      =          .
                                                          Prob > chi2       =          .
          Log pseudolikelihood = -36.462189               Pseudo R2         =     0.1903
          
                                          (Std. Err. adjusted for 2 clusters in foreign)
          ------------------------------------------------------------------------------
                       |               Robust
               foreign |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                 price |    .000266   .0001199     2.22   0.027     .0000309    .0005011
                   mpg |   .2338353   .0614319     3.81   0.000     .1134309    .3542396
                 _cons |  -7.648111   .0981982   -77.88   0.000    -7.840576   -7.455646
          ------------------------------------------------------------------------------
          
          . predict residual, res
          
          . egen res_sd=sd(residual)
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Carlo,

            Thank you for your help! Does the command of "predict stdr, stdr" produce the same information as your suggested command of "egen res_sd=sd(residual)." If that is the case, why the former command did not work and generated the error message of "option stdr not allowed r(198);"

            Comment


            • #7
              DY:
              because -predict stdr, stdr- is not part of -logistic- or -logit- postestmation routines.
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment

              Working...
              X