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]
Re: st: looping twice over same variables without repeating results
From
Beatriz Rodriguez Prado <[email protected]>
To
[email protected]
Subject
Re: st: looping twice over same variables without repeating results
Date
Fri, 18 May 2012 12:31:56 +0200
Thank you Nick.
The other question you raise is my problem. Sorry it was not clear.
I do not want to regress y on x and x on y. I just want one of two
regressions.
Beatriz
El 18/05/2012 12:03, Nick Cox escribió:
Your question raises another which is whether you want the regression
of y on x _and_ the regression of x on y.
foreach x of local varlist {
foreach y of local varlist {
if "`x'" != "`y'" regress `y' `x'
}
}
is a safer and better way to avoid -regress-ing a variable on itself
but it will produce all the other p (p - 1) regressions for p
variables.
Nick
On Fri, May 18, 2012 at 10:52 AM, Beatriz Rodriguez Prado
<[email protected]> wrote:
I have 3 variables named pmm_and pmm_ext pmm_es and I want to make simple
regressions of each pair of variables.
I have writen this code
foreach x in and ext es {
foreach y in and ext es{
if pmm_`x'!=pmm_`y' {
regres pmm_`x' pmm_`y'
}
}
}
How could avoid to run repeated regressions?
In fact I have 50 variables and have to run regressions, test some
hyphotesis and make graphs and the output of the loop is unnecesary big.
*
* 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/
*
* 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/