Announcement

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

  • Replicating Excel Intercept/Slope

    I have four variables, y1-y4 that I would like to regress on four fixed x's, x1-x4. (I have taken the logs of both the x's and y's). For each observation/row, I wanted to fit a line and capture the intercept and slope. In excel, it would be Intercept(y1-y4,x1-x4) and the same for Slope. I would then copy the command for each row. I cannot figure out how to do this in Stata. Any help is greatly appreciated. Thank you.

  • #2
    foreach i of numlist 1/4 {
    reg y`i' x`i'
    gen y`i'cons =_b[_cons]
    gen y`i'slope =_b[x`i']
    }

    Comment


    • #3
      Thank you very much.

      Comment

      Working...
      X