Announcement

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

  • Using loop within a loop to run regressions


    Hi,

    I am working on firm level data sets in India. For my work, I have a set of outcome variables such as Export Intensity, Labor Productivity, Share of Services in total sales, etc. and a set of 7 explanatory variables (1-7) in addition to 4 controls. I want to run regressions with different combinations of explanatory variables say taking only 1 in the first, then 1 and 2, and so on. For this I thought, I will run a double loop in stata where in the first loop I will state my outcome variables, then, in the second loop, I will state my set of explanatory variables, followed by the regression equation and outreg command. However, I could not succeed in formulating a correct command. Could you please help me in generating the stata command?/
    thank you so much

  • #2
    Don't do this.
    If you have a theoretical foundation to include these seven explanatory variables in your model, then include them.
    If you're fishing for statistically significant variables, you could look into stepwise models. https://www.stata.com/manuals13/rstepwise.pdf
    Before you proceed, however, search the literature and online educational material on discussions on when to use stepwise regression. You will not find many proponents.

    Comment


    • #3
      Sughanda:
      please be also advised about the pitfalls of stepwise regression models: https://www.stata.com/support/faqs/s...sion-problems/
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment


      • #4
        I didn't read Sugandha as intending to do stepwise regression. It sounded to me more like

        Code:
        local controls c1 c2 c3 c4
        
        foreach response in y1 y2 y3 {
               nestreg : regress `response' `controls'  x1 (x2) (x3) (x4) (x5) (x6) (x7)
        }

        Comment


        • #5
          Thank you so much everyone for your replies. I am sorry, if i was not able to frame my question appropriately but I am not intending to do a stepwise regression. Apologies
          Thank You Nick Sir for understanding my question and for your response too.
          Thanks a lot

          Comment

          Working...
          X