Announcement

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

  • Normalized residual squared

    Hello Stata user,

    I was working on a special leverage plot I wanted to create with "twoway scatter". Therefor I was calculating the "normalized residual squared" the lvr2plot is using. But I have some problems. I have found the equation in the Stata help:
    Click image for larger version

Name:	norm_resid.png
Views:	1
Size:	29.7 KB
ID:	1647676

    As far as I can see that correctly, e_i_hat is the residual (difference between my y variable and the predicted y value). But which residual is e_j ?

    Thanks
    Nick

  • #2
    It's the \(j\;^{th}\) residual that you want to normalize. Obviously, it will be confusing to index it as \(i\) given that you also define \(i\) as an arbitrary index of all other residuals that you are summing in the denominator.
    Last edited by Andrew Musau; 01 Feb 2022, 05:26.

    Comment


    • #3
      What I wanted to do ist the following:

      clear
      sysuse auto
      reg price weight
      lvr2plot

      I wanted to create this plot for my own by using:

      predict lev, leverage
      predict resid, resid
      gen resid2 = resid*resid
      qui: su resid2
      gen e_nj = resid / sqrt(`r(sum)')
      twoway scatter lev e_nj // not the same x-axis like lvr2plot

      But my normalized squared residuals aren't the same as in lvr2plot. So what's wrong calculating e_nj in my code?

      Thanks again
      Nick

      PS. Didn't know I can use Latex Code here. How did you write j_th in your post?

      Comment


      • #4
        You almost have it right, but the x-axis is the square of the normalized residuals.

        Code:
        gen e2_nj = e_nj^2
        twoway scatter lev e2_nj


        PS. Didn't know I can use Latex Code here. How did you write j_th in your post?
        Code:
        \[ LATEX CODE \]
        where you change the square brackets to parentheses.

        Comment


        • #5
          Ahhh! Thank you! I was totally blind to "squared"! Thank you so much, also for the Latex.

          Comment

          Working...
          X