Announcement

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

  • Regress y on each variable each time

    Hi,

    I want to run regressions in the following way:

    reg y x1 i.year i.ind
    reg y x2 i.year i.ind
    reg y x3 i.year i.ind
    reg y x1 x2 x3 i.year i.ind

    It seems that stepwise is not the solution. Is there any faster or more concise way of doing this?

    Thanks

  • #2
    If it is just these four regressions you need to run, then I don't think there is a better way to do it. You could write a loop, but the lines of code for the loop itself would be as numerous as the lines of code you would eliminate, and it would be less transparent.

    If however, it's not just three different x's, but a large number, then a loop would make sense. Something like this:

    Code:
    local predictors x1 x2 x3 // ETC.  ADD ALL THE RELEVANT VARIABLES
    foreach v of varlist `predictors'  {
        reg y `v' i.year i.ind
    }
    regress y `predictors' i.year i.ind

    Comment

    Working...
    X