Hello everyone,
I'm trying to run a number of regressions over local macros. I won't display my data as it's not complex but just too big and I'd rather describe it.
I have multiple variables named x and y that are numbered 1-10 and 1-5 as identifiers. With these 50 pairs of variables, I want to run 50 regressions. I guess the answer lies somewhere between macros and loops, but I can't get it right.
Here's an excerpt of my data:
I tried this, but it doesn't regress the individual pairs:
To make it even clearer, this would be the long version for what I need:
Any ideas?
Thank you
Moritz
I'm trying to run a number of regressions over local macros. I won't display my data as it's not complex but just too big and I'd rather describe it.
I have multiple variables named x and y that are numbered 1-10 and 1-5 as identifiers. With these 50 pairs of variables, I want to run 50 regressions. I guess the answer lies somewhere between macros and loops, but I can't get it right.
Here's an excerpt of my data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(x_1_1 y_1_1 x_2_1 y_2_1 x_1_2 y_1_2 x_2_2 y_2_2) end
Code:
local indepvar y*
foreach depvar of varlist x* {
eststo: quietly reg `depvar' `indepvar', noheader
}
Code:
eststo: quietly reg x_1_1 y_1_1 eststo: quietly regx_2_1 y_2_1 ... eststo: quietly reg x_10_1 y_10_1 ... eststo: quietly reg x_1_2 y_1_2 eststo: quietly regx_2_2 y_2_2 ... eststo: quietly reg x_10_2 y_10_2 ... eststo: quietly reg x_1_5 y_1_5 eststo: quietly regx_2_5 y_2_5 ... eststo: quietly reg x_10_5 y_10_5
Thank you
Moritz

Comment