Dear forum members
I am trying to run regression in loop. This post is for confirming my code.
I my understanding, and what results window shows, it run regression for each depvars with three specification. It will first run the three specification for sout and so on for others.
Is it right way for looping or more efficient and correct ways are there.
Thank you
I am trying to run regression in loop. This post is for confirming my code.
Code:
// Define dependent variables local depvars sout prfood prcheck prchnedu // Define independent variable groups local group1 i.v025 i.v190 local group2 i.v025 i.v190 i.caste i.religion local group3 i.v025 i.v190 i.caste i.religion i.v151 i.odfunimp // Loop over dependent variables foreach y of local depvars { // Loop over independent variable groups forvalues g = 1/3 { // Assign group of independent variables if `g' == 1 { local indepvars `group1' } else if `g' == 2 { local indepvars `group2' } else { local indepvars `group3' } // Run regression reg `y' `indepvars' // display separator di "===============================NEW Specification===============================" // di "===============================================================================" } }
Is it right way for looping or more efficient and correct ways are there.
Thank you
Comment