Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: how to create a loop for all the feasible regressions in a varlist


From   Stefano Lombardi <[email protected]>
To   [email protected]
Subject   st: how to create a loop for all the feasible regressions in a varlist
Date   Wed, 23 Mar 2011 22:42:16 +0100

Dear all,

Starting from a list of 4 variables, I need to:
    - regress var1 on var2, var3, var 4
    - regress var2 on var1, var3, var4
and so on..
Basically I need to create a loop where every time the dependent variable is regressed on all the three others.

I have been trying to use the "foreach" command, but I cannot find the right way to solve the issue. In fact if I type:

 foreach x in Gasp PNC PUC PPT {
    reg `x' Gasp PNC PUC PPT
    }

the software, obviusly, every time returns an erroneous model (R^2 = 1), because in each model the dependent variable is explained by itself.. The point is that I have no idea on how to remove the `x' variable from the regressors list.

Thank you everyone in advance,

Stefano Lombardi
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index